How to Compare 2 Variables

Dear UiPath Gurus.

I need some help in the following work flow.

i Data Scrap a Drop down Box and managed to get all the Data from the List. These List are basically Dates.

I have assign 2 Variables. The First variable has a fix date of “01-Sept-2019” an the second variable is read of from a Data Table where i have scrap the data. The sequence will will loop reading of the Data Table and comparing it with the First variable.

On my IF Condition I have done the logic in this manner:-

(varDateFind.Equals( row.Item(0).ToString))

What I am trying to accomplish is to check if the first fixed variable with the date “01-Sept-2019” is equal to the Date that is in the Data Table.

If it “YES” then it Display a Message “Found” and if “NO” then display it display a message “NO”
i can display the message count which show’s 5 which means there are 5 rows that i have Data Scrape.

image

I managed to also display the contents of the Data Table but some how my IF Logic is not working when I do the comparison. Below are my flows.

Can you show me where i went wrong?

Regards
Subas

“sept” vs “sep” ?

Dear @msan

Thank you for pointing that out. The search work well now. Not sure how I can miss that out :thinking:

Now the output on the Message box shows Found. I not sure how to get the row number where the both variable are the same. i have tried the flow below but its showing “0” when found.

image

Below is the flow. Can you please assist in how i can display that Row number?

image

Regards
Subas

@subasc - Can you try with
1 - Log the row.Item(0).ToString before if condition - to check the value
2- varDateFind.Contains(row.Item(0).ToString)
or
varDateFind.ToString.ToLower.Contains(row.Item(0).ToString.ToLower)

dear @GBK

Thank you for coming back to me so fast. really appreciate it.
I did as instructed and now the out shows “True” when both variables are equal.

image

The changes i made to the flow is shown below except i was not sure how to Log the result as instructed by you.

I need the row number when its true. Could you please help to suggest what would be the best way to get the Row number please?

Regards
Subas

Dear @GBK.

Just to update you and everyone else, I have push the message to the output screen and it detects the Date that I am trying to look for in the Data Table with a “True”.

image

As you can see your solution worked. The Date “01-Dec-2019” is on the 3rd loop as such I want the system to give the number of loops it went through to detect that Date that I am searching for. For this example is loop 3.

I have use a IF activity but it is giving me an error. I am not sure if this is the way to go to obtain the the number of loops. In the IF activity i tried to detect if it contains the “True” as shown on the output screen and if it does come out of the IF activity and write the Counter value.

image

image

image

Need some help on the above issue please.

Regards
Subas

pls change the variable varfoundcount type to Boolean…
in if condition just check varfoundcount
no need to write contains statement for boolean variables

Dear @GBK

I have changed the varablw to Boolean as per the below screen shot

i also changed the IF activity to remove the “Contain” as per below

image

The error i get now is as per below

image

Please help.

Regards
Subas

  • pls assign default value for varFoundCount as false in variable panel

  • in if condition - no need to mention about the true or false
    just mention the variable name in condition…

  • change the variable varcounter type as Int32 and assign default value as 0

Dear @GBK

Thank you so very much :pray: :pray: :pray: :pray:. It work’s perfectly.
The count is “2” as per below screen shot when i search for “01-Dec-2019”

image

image

A million thank you @GBK and everyone else that had helped me on this quest.

Best Regards
Subas

1 Like

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