Match part of the text and replace with another text in excel - excel-match

I've data table with list of names which are having few differences. I am trying to change those text to similar name within data table as image in below.
If part of the text in cells in data table are matching with the "Abbreviations" list(Col-AK) then Data table text must replace with the text in "To be replaced" (Col-AL) into "Expected Return Table". I've tried using may different functions to accomplish my ultimate target, but none of them is giving perfect answer.
Can anybody help me with this problem.

I found an answer to my problem. I could do this using below formula.
Step 01:- I've used below static formula at first to identify the dynamic formula
=IF(LEFT(AC2,4)=$AK$2,$AL$2,AC2)
Step 02:- Then I've used Index function to return the first text in abbreviation list which is Iodine by only changing partial of the formula to return only single value avoiding others. Ex: Firstly I considered only about the Iodine in the list. This will only replace Iodine into the expected data table.
=IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,1),$AL$2,AC2)
Step 03:- Then row_num turned into dynamic and expanded the return text data into range($AL$2:$AL$11) from single($AL$2) using Match & Left function as below.
=IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),INDEX($AL$2:$AL$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),AC2)
Step 04:- Finaly ignore errors using IFERROR Function.
=IFERROR(IF(LEFT(AC2,4)=INDEX($AK$2:$AK$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),INDEX($AL$2:$AL$11,MATCH(LEFT(AC2,4),$AK$2:$AK$11,0)),AC2),"")
Expected Return Data Table as shown below.

Related

Power Query - conditional replace/clear entire cell in multiple columns

I'm trying to clear the entire cell if it doesn't contain a given keyword.
I've managed to do this for one column:
Table.ReplaceValue(#"PrevStep",each [#"My Column"], each if Text.PositionOf([#"My Column"],"keyword")>-1 then [#"My Column"] else null,Replacer.ReplaceValue,{"My Column"})
The problem is I need to iterate/repeat that step for a number of columns... the number of columns may vary and column names also may be different every time. I can have all those column names put into a list but I'm not able to use it.
The solution I'm looking for may look like this
for each ColNam in MyColumnsList
Table.ReplaceValue(#"PrevStep",each [#"ColNam"], each if Text.PositionOf([#"ColNam"],"keyword")>-1 then [#"ColNam"] else null,Replacer.ReplaceValue,MyColumnsList)
next
but this is not the VBA code but Power Query M - and of course the problem is with #PrevStep as I would see it like a recursions... again... do not know how to process.
Is the path I follow correct or should it be done some other way
Thanks
Andrew
Unpivot your columns to turn all the columns into two columns. Apply your replacement to the single value column then pivot it back into the original format

Referencing fields in BI Publisher RTF template conditional regions

I'm putting together a report in the BI Publisher Word .rtf plugin with very specific layout needs. One of those needs is the ability to switch company logos depending on parameters entered. I've been using conditional fields to selectively display each logo, but for some reason I can't reference data fields in the conditional code.
I've used these methods:
<?if: column_name = 'desired_value'?> [logo1] <?end if?>
<?choose:?><when: column_name = 'desired_value'?> [logo1] <?end when?>
Both of these methods seem to work when given raw values (i.e. instead of column_name = desired_value, I used 1=1 and it printed) but not when I use the name of the column I'm trying to compare.
For a more concrete example:
<?if: p_jno_in > 0?>
is always false, as if p_jno_in is null rather than having a value. (this variable represents the job number of the report and will never be null, even in my test data/sample xml.)
EDIT: Here is an example of what I've used, and the output.
If you host the image on the server, you can do all sorts of stuff with BI Publisher logic and concatenating an image path string. Make sure you or your DBA makes the path readable by BI Publisher. They can also map it to an FTP connection so you can edit/add images without being in Unix.
Insert any dummy placeholder image in RTF template (Insert Picture)
Right click on image and click “Edit Alt Text” and enter dynamic path. (See below for example)
url:{concat('${OA_MEDIA}/XX_LOGOS',/XML_PATH/LOGO_NAME,'_','small','.jpg')}
Other older versions of Word may have this data stored in the Size/AltText or Format Picture/Web menus
I looked around a bit and found the answer to my question. Turns out I was actually using the correct format the whole time! The issue was actually that I was referencing fields inside a for-each grouping, which I think might limit the scope. So, for example, if my BI Publisher data model has a query block A that has been split into two groups AA and AB, trying to reference a field from AA when you're in a for-each looping on an element from AB will not work.

How to read an excel sheet and put the cell value within different text fields through UiPath?

How to read an excel sheet and put the cell value within different text fields through UiPath?
I have a excel sheet as follows:
I have read the excel contents and to iterate over the contents later I have stored the contents in a Output Data Table as follows:
Read Range - Output:
DataTable: CVdatatable
Output Data Table
DataTable: CVdatatable
Text: opCVdatatable
Screenshot:
Finally, I want to read the text opCVdatatable in a iteration and write them into text fields. So in the desired Input fileds I mentioned opCVdatatable or opCVdatatable+ "[k(enter)]" as required.
Screenshot:
But UiPath seems to start from the begining of the Output Data Table whenever I called for opCVdatatable.
Inshort, each desired Input fileds are iteratively getting filled up by all the data with the data stored in the Output Data Table.
Can someone help me out please?
My first recommendation is to use Workbook: Read range activity to read data from Excel because it is quicker, works in the background, and does not require excel to be installed on the system.
Start your sequence like this (note the add headers property is not checked):
You do not need to use Output Data Table because this activity outputs a string containing all row items. What you want to do instead is to access the items in the data table and output each one as a string in your type into, e.g., CVDatatable.Rows(0).Item(0).ToString, like so:
You mention you want to read the text opCVdatatable in an iteration and write them into text fields. This is a little bit more complex, but i'll give you an example. You can use a For Each Row activity and loop through each row in CVDatatable, setting the index property if required. See below:
The challenge is to get the selector correct here and make it dynamic, so that it targets a different text field per iteration. The selector for the type into activity will depend on the system you are targeting, but here is an example:
And the selector for this:
Also, here is a working XAML file for you to test.
Hope this helps.
Chris
Here's a different, more general approach. Instead of including the target in the process itself, the Excel would be modified to include parts of a selector:
Note that column B now contains an identifier, and this ID depends on the application you will be working with. For example, here's my sample app looks like. As you can see, the first text box has an id of 585, the second one is 586, and so on (note that you can work with any kind of identifier including the control's name if exposed to UiPath):
Now, instead of adding multiple Type Into elements to your workflow, you would add just a single one, loop over each of the datatable's row, and then create a dynamic selector:
In my case the selector for the Type Into activity looks as follows:
"<wnd cls='#32770' title='General' /><wnd ctrlid='" + row(1).ToString() + "' />"
This will allow you to maintain the process from the Excel sheet alone - if there's a new field that needs to be mapped, just add it to your sheet. No changes to the Workflow are required.

Split a Value in a Column with Right Function in SSIS

I need an urgent help from you guys, the thing i have a column which represent the full name of a user , now i want to split it into first and last name.
The format of the Full name is "World, hello", now the first name here is hello and last name is world.
I am using Derived Column(SSIS) and using Right Function for First Name and substring function for last name, but the result of these seems to be blank, this where even i am blank. :)
It's working for me. In general, you should provide more detail in your questions on places such as this to help others recreate and troubleshoot your issue. You did not specify whether we needed to address NULLs in this field nor do I know how you'd want to interpret it so there is room for improvement on this answer.
I started with a simple OLE DB Source and hard coded a query of "SELECT 'World, Hello' AS Name".
I created 2 Derived Column Tasks. The first one adds a column to Data Flow called FirstCommaPosition. The formula I used is FINDSTRING(Name,",", 1) If NAME is NULLable, then we will need to test for nullability prior to calling the FINDSTRING function. You'll then need to determine how you will want to store the split data in the case of NULLs. I would assume both first and last are should be NULLed but I don't know that.
There are two reasons for doing this in separate steps. The first is performance. As counter-intuitive as it sounds, doing less in a derived column results in better performance because the SSIS engine can better parallelize the operations. The other is more simple - I will need to use this value to make the first and last name split so it will be easier and less maintenance to reference a column than to copy paste a formula.
The second Derived Column is going to actually perform the split.
My FirstNameUnicode column uses this formula (FirstCommaPosition > 0) ? RTRIM(LTRIM(RIGHT(Name,FirstCommaPosition))) : "" That says "If we found a comma in the preceding step, then slice out everything from the comma's position to the end of the string and apply trim operations. If we didn't find a comma, then just return a blank string. The default string type for expressions will be the Unicode (DT_WSTR) so if that is not your need, you will need to cast the resultant into the correct string codepage (DT_STR)
My LastNameUnicode column uses this formula (FirstCommaPosition > 0) ? SUBSTRING(Name,1,FirstCommaPosition -1) : "" Similar logic as above except now I use the SUBSTRING operation instead of RIGHT. Users of the 2012 release of SSIS and beyond, rejoice fo you can use the LEFT function instead of SUBSTRING. Also note that you will need to back off 1 position to remove the comma.

iReport + XPath - Sum String Column

I'm building a report where I have a subreport. This subreport brings some data through XPath, this means it's everything strings from a XML. One of the columns of this subreport has some values, where I need do sum them and show in the end of the table.
I don't know how to put this to work. I've tried to create a variable with sum parameter, but it does not work.
Did anybody need this before?
Scenario:
I load a lot of values from a XPath query, e.g:
/something/something1/something2
This query returns some fields according to my needs. With them I build a table (in a subreport). The problem is: the last column (4), values are strings from XML.
iReport version: 3.0.0
Really thanks!
Solution:
What I needed? According to the original post, a column with strings read from a XML through XPath and a footer with the sum.
Result from column SUM
What to do? Create a variable where you'll keep your sum. After created, edit it. e.g:enter image description here
Fill variable expression with the format you need. Here I used
new BigDecimal($F{theFieldToSum});
Click ok. Now the variable is created, you must create a new TextField where you'll show your sum. Create it and edit it. Here I used the following format:
new java.text.DecimalFormat("#,##0.00").format($V{theVariableYouCreatedBefore})
Click "Apply" and that's all. Compile your report and now you'll have the expected result. For sure, you can do some adapt, but in general this is the process.

Resources