Getting invocation error for false statement

I have two Notepad data1 and data2. I am trying to add a column (Result) to data1 on condition that

  1. Column named TAX_TYPE (of data1) = TAX (of data2)
    And
  2. TAX_RATE (of data1) = Percent (of data2)

The column (Result) which is supposed to get added to data2 notepad will have true or false based on the above condition

Can anyone help to get a working flow

Data1
wade.txt (1.8 KB)
Data2
test1.txt (1.5 KB)

@dipon1112000

  1. Read Data from Notepads:
  • Use “Read Text File” activity to read data1 and data2 into strings.
  1. Convert Text to DataTable:
  • Use “Generate Data Table” activity to convert the strings from step 1 into DataTables (DataTable1 and DataTable2).
  1. Add Column to DataTable1:
  • Use “Add Data Column” activity to add a new column named “Result” to DataTable1.
  1. Use For Each Row:
  • Use “For Each Row” activity to iterate through each row in DataTable1.
  1. Check Conditions and Update Result Column:
  • Inside the “For Each Row” activity, use an “Assign” activity to set the value of the “Result” column based on conditions.

row(“Result”) = If(row(“TAX_TYPE”).ToString = DataTable2.Rows(rowIndex)(“TAX”).ToString AndAlso
row(“TAX_RATE”).ToString = DataTable2.Rows(rowIndex)(“Percent”).ToString, True, False)

I am getting this error

Can anyone help please

Data in Notepads are CSV data. So we can use Read CSV Activity

You can start and exploring Join DataTable (Left Join dt1 to dt2)

Afterwards we will postprocess the Join Result and can update / generate the marked Data1 as needed

Hey @dipon1112000
you can try this solution:
BlankProcess70.zip (4.2 KB)

Thank you so much but the result is coming false for all the rows

Kindly note on some heade cleansings is recommended (more below)

Have a look at this lookup dict approach

dictLK = Dictionary(Of String, String) =

dtData1.AsEnumerable.ToDictionary(Function (x) x(2).toString.Trim, Function (x) x("TAX_RATE").toString.Trim)

grafik

So in a second step dt1 can be extended with the status column and can be updated by using the lookup dict for the Code and cheking the rate when looping over dt2


Giving some more starter help:
Preps

Check

strKey = row2(“TAX”).toString.Trim
IF Condition
dictLK.ContainsKey(strKey) AndAlso dictLK(strKey).Equals(row2(“Percent”))


We do feel:

  • a few corrections are to do (at least the column issue from dt1 can lead to wrong LookUpDict
  • maybe the Percentage precions 0.5 vs 0.5000000001 are to harmonize

Feel free to adapt and to enhance

Hi @dipon1112000

Try this:
Test.zip (2.7 KB)

Hope it will helps you.

Happy Automation :slight_smile:

You are missing the double quotes around TAX_TYPE - it should be row(“TAX_TYPE”) not row(TAX_TYPE). Also, rowIndex appears not to be declared. What do you have in the index property of the For Each Row in Data Table activity?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.