Hello, I am a beginner using Uipath and I am looking for some help. I have two columns in Excel column A and B. I want compare each row in A with B using an IF statement. IF the number in A > B then subtract Else multiply, and have the answer in the Result column.
Column A = 2 Column B = 3 Results = 6
Because column A is less than B we multiply.
Column A = 4 Column B = 2 Result = 2
Because column A is grater than B we subtract. How would I create this state in the IF activity?
First you need to use Read Range activity to get data from excel and store it as DataTable variable.
Then use For Each Row to loop into row and in looping you use IF statement
If (Int32.parse(row(“A”).ToString) > Int32.parse(row(“B”).ToString))
Then → Result = Int32.parse(row(“A”).ToString) - Int32.parse(row(“B”).ToString)
Else → Result = Int32.parse(row(“A”).ToString) * Int32.parse(row(“B”).ToString)
(Assuming your column name is “A” and “B”)
To compare value or calculate value as integer or decimal from data from excel, you need to convert it to data type as you want. Above example is to convert it to Integer(32) data type.