How to output data with 1 correct condition?

Hi,

I got an activity like this :

My company have 2 type of insurance (Insurance A and Insurance B)

Each customer can have different insurance period (example John Doe having 3 year of insurance period, and Jane Doe having 4 year insurance period)

And each customer can have 2 type of insurance in their insurance period, example :

John Doe : 3 Years insurance
Year 1 : Insurance A
Year 2 : Insurance B
Year 3 : Insurance A

Jane Doe : 4 Years Insurance
Year 1 : insurance B
Year 2 : Insurance A
Year 3 : Insurance A
Year 4 : Insurance A

I need to output what year does the customer having Insurance A. So the output will be :

John Doe : Insurance A (Year 1,3)

Jane Doe : Insurance A (Year 2,3,4)

I alrd got the year, and the insurance type, but I don’t get the logic on the if section. Can any1 help me with this automation?

@Rhys18

But it’s not clear what was your input?

Thanks

So far I haven’t do anything yet with the if because I don’t get the logic how to output it. The only thing I think of is nested if, but the consequences the robot will be heavy because there’s a lot of process (if its 8 insurance period, then its 7 if inside an if)

@Rhys18

Can you tell us what was the input or which variable you are storing this info?

Thanks

The variable I am storing is 2

Year : Contains Tenor Year (1, 2 ,3)
Ins_Type : the insurance type (Insurance A, Insurance B)

@Rhys18

Has your Input come from Excel?

Thanks

The input is coming from a filtered json. So I query the insurance detail with SQL query activity inside the uipath, and filtered it with json to data table activity then I pass it to a variable like this
image

I’m not too familiar with filtered json or the data structure you’re using, but for variables, it fits in a dictionary. The key would be the Employee name and the value would be another dictionary <insurance;year> pair of key/value.

You could use loops to print the years of insurance A and B by populating a string array inside a ‘for each’ loop, it would probably look like this.

I tried ur solution and somehow it keeps adding when I use string.join function the output is like this :

Expected Output
John Doe : Insurance A (Year 1,3)
Jane Doe : Insurance A (Year 2,3,4)

System Output
John Doe : Insurance A (Year 1,3)
Jane Doe : Insurance A (Year 1,3,2,3,4)

Have tried clear collection, remove data table at the end of the process it’s still not working somehow

Thanks for ur help !!

I stored the variable in a dictionary, using if inside it for the insurance, then at the very early I declare a variable and put the value as :

Ins_Var = “”

and the output is expected as I want. Thank you so much !

1 Like

I’m glad I could help you! Thanks for marking it as solution!

Thanks a lot and your welcome ! Hv a nice day

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