Conditional If/Then Statements

Hi, i’m trying to write some conditional If/Then statements within the IF activity in my workflow. I am attaching a excel sheet of some dummy variables with the same column names I have in my worksheet.
dummy variables.xlsx (10.1 KB)

I’m trying to run a few tests which for some reason are not working. I have the if/then statement setup properly and the tests run properly for some of the simpler tests but the more complex one’s are eluding me.

For example: I want to test if an expense is paid for by the company but it’s not related to airfare or hotels which is a violation.

What i’ve tried so far is:
(PaymentType.Equals(“Company Paid”) And (ExpenseType=Not(“Hotel”) Or ExpenseType =Not(“Hotel Tax”) Or ExpenseType =Not(“Airfare”) Or ExpenseType =Not(“Airline - Baggage Fee”)))

I have also tried
(PaymentType.Equals(“Company Paid”) And (ExpenseType.IsNot(“Hotel”) Or ExpenseType.IsNot(“Hotel Tax”) Or ExpenseType.IsNot(“Airfare”) Or ExpenseType.IsNot(“Airline - Baggage Fee”)))

I also want to run a test that determines if the expense is paid for using the BofA mastercard and is a business expense.

How I tested that is"
Payment Type <> (“BofA Mastercard”) AND expense type = (“Meals - Trip Overnight”)
Payment Type <> (“BofA Mastercard”) AND expense type = (“Car Rental”)
Payment Type <> (“BofA Mastercard”) AND expense type = (“Meals - Clients”)

I was not able to Nest all of the conditions into one statement so I ended up creating 9 different if statements, one for each statement. If you could help me learn how to nest these conditions into one statement, that would be a huge help.

Thank you!

For this condition hope the below expression would help you with
But before that
—use a excel application scope and pass the file path as input
—inside the scope use READ RANGE activity and get the output with a variable of type datatable named dt
—now use a FOR EACH ROW activity and pass the above variable as input
Inside that use a IF condition replacing this

row(“PaymentType”).ToString.Equals(“Company Paid”) AND
NOT row(“ExpenseType”).ToString.Equals(“Hotel”) OR
NOT row(“ExpenseType”).ToString.Equals(“Hotel Tax”) OR
NOT row(“ExpenseType”).ToString.Equals(“Airfare”) OR
NOT row(“ExpenseType”).ToString.Equals(“Airline - Baggage Fee”)

And for this

NOT row(“PaymentType”).ToString.Equals(“BofA Mastercard”) AND
row(“ExpenseType”).ToString.Equals(“Meals - Trip Overnight”) OR
row(“PaymentType”).ToString.Equals(“BofA Mastercard”)AND
row(“ExpenseType”).ToString.Equals(“Car Rental”)
row(“PaymentType”).ToString.Equals(“BofA Mastercard”) AND
row(“ExpenseType”).ToString.Equals(“Meals - Clients”)

Hope this would help you
Change the condition for the last one alone based on your need with AND , OR operator

Cheers @hall1570

1 Like

Very helpful, this is exactly what I was looking for. I hope you have a great day.


Within this same database, I have a column for employee. Our company does not allow the upgrading of airfare from economy unless the employee is a group A or Group B employee.

I want to add a new variable for group A employees and a new variable for group B employees.

That way, I can use these two variables to exempt them from that policy. How would I do that?

I have added the code you recommended to the conditional statement. It is right below.

row(“Payment Type”).ToString.Equals(“BofA Mastercard”) And
Not row(“Expense Type”).ToString.Equals(“Meals - Clients & Co Staff”) Or
Not row(“Expense Type”).ToString.Equals(“Hotel Phone/Internet”) Or
Not row(“Expense Type”).ToString.Equals(“Car Rental”) Or
Not row(“Expense Type”).ToString.Equals(“Car Rental - Gas”) Or
Not row(“Expense Type”).ToString.Equals(“Meals - Trip No Overnight Stay”) Or
Not row(“Expense Type”).ToString.Equals(“Taxi”) Or
Not row(“Expense Type”).ToString.Equals(“Hotel Tax”) Or
Not row(“Expense Type”).ToString.Equals(“Parking”) Or
Not row(“Expense Type”).ToString.Equals(“Hotel”) Or
Not row(“Expense Type”).ToString.Equals(“Meals - Trip Overnight”)

What this should be testing is: if in the column Payment Type, the row value should read "BofA Mastercard.

In the Column for expense type, the row value should not equal Meals- Clients - Co Staff
In the column for expense type, the row value should not equal Hotel Phone/Internet

I understand this logic but when I run the tests, it creates a new table that includes all of the values from my read range activity. For some reason, the code broke the program. I am attaching my studio workbook below.
WritingConditionStatementInExcel.xaml (72.3 KB)

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