Variable and If Statement Question

Hi All,

We’re working with an excel spreadsheet to make some changes in our CRM. Column D tells us the type of business and Column C tell us if it’s an a subsection of that business. I need to make a rule that says if Column D = PL, check if Column C= VIP, if yes do XYZ. If Column D= CL, do XYZ. How to I set the variable correctly, to be able to use an If Statement?

Thank you!

You can use set excel formular by write cell activity in UiPath

Hi @sjavits-cohan

Excel Application Scope (Specify Excel file path)
   └─ Read Range (Output: dtData)

For Each Row (ForEachRow in dtData)
   └─ If (row("ColumnD").ToString = "PL")
      ├─    If (row("ColumnC").ToString = "VIP")
      │      └─ XYZ actions
      ├─ Else If (row("ColumnD").ToString = "CL")
      │      └─ XYZ actions
      └─ End If

Answered By LLM to better organization, hope that helps

Regards!

HI,

Can you try as the following?

Open advanced editor then input the following expression as condition

(CurrentRow.ByIndex(2) = "PL" AndAlso CurrentRow.ByIndex(3) = "VIP") OrElse CurrentRow.ByIndex(2) = "CL"

Note: In this case, 2 is column C and 3 is column D if the table starts from A1.

Regards,

Hello

You can achieve this using a single IF Condition activity or two if you prefer.

Single IF Condition
Condition:
((row(“COLUMND”).ToString = “PL”) and (row(“COLUMNC”).ToString = “VIP”)) Or (row(“COLUMND”).ToString = “CL”)
Then:
Do XYZ
Else:
Do Nothing

Two If Conditions
If Statement #1
Condition:
(row(“COLUMND”).ToString = “PL”) and (row(“COLUMNC”).ToString = “VIP”)
Then:
Do XYZ
Else:
Do Nothing

If Statement #2
Condition:
row(“COLUMND”).ToString = “CL”
Then:
Do XYZ
Else:
Do Nothing

.

.

Note:

  • you need to swap out the capital letters for actual column names.
  • you may need to put the values to upper and trim depending on your data (.ToUpper.Trim)

Cheers

Steve