Function and methods related to Datatable

Hello All,

My Doubt/Question here is, there is a practice test in academy were i designed the flow and it works as excepted, but some methods and functions usage gives me wrong result.

i’m not sure whether this question is correct tor not, since i’m beginner to UiPath and related to codes too :slight_smile:

Expected result is:-

when i give the below in 1st if condition.
Not IsNumeric(Row(“Cash In”).ToString) And Not IsNumeric(Row(“Cash out”).ToString)

and in 2nd if condition as,

Int32.TryParse(Row(“Cash In”).ToString,0)

the below is the correct result

were i have the values that contains some alphabetical letters either in col1 and col2 or col 1 alone and vice versa.

Variables that i declared:

ConvertCashIn= cint(Row(1).ToString)
ConvertCashOut= cint(Row(2).ToString)

Month Cash In Cash out Difference Status
May-15 15 241 -226 Correct
Jun-15 77 90 -13 Correct
Jul-15 64 44 20 Correct
Aug-15 13K 130 NA Cash In value is incorrect
Sep-15 144 78 66 Correct
Oct-15 160 150K NA Cash out value is incorrect
Nov-15 14O 13 NA Cash In value is incorrect
Dec-15 33 49 -16 Correct
Jan-16 134 169 -35 Correct
Feb-16 37K 5K NA Both the values are incorrect

Now, i get the wrong result when i use this in condition as,

Please assist me on this, whether i override the rules or not :slight_smile: due to which i’m not getting the output with other possibility.

After the above if else condition i’m getting the below output which is not the expected one.

Month Cash In Cash out Difference Status
May-15 15 241 -226 Correct
Jun-15 77 90 -13 Correct
Jul-15 64 44 20 Correct
Aug-15 13K 130 NA Cash out value is incorrect
Sep-15 144 78 66 Correct
Oct-15 160 150K NA Cash out value is incorrect
Nov-15 14O 13 NA Cash out value is incorrect
Dec-15 33 49 -16 Correct
Jan-16 134 169 -35 Correct
Feb-16 37K 5K NA Cash out value is incorrect

Hi @_Anish,

Welcome to UiPath Forum.:slight_smile:

your can use Nested IF for this, check this workflow

Input
image

Output
image

Workflow

Code:
If(IsNumeric(Row("Cash In").ToString),If(IsNumeric(Row("Cash Out").ToString),"Correct","Cash Out Value is Incorrect"),"Cash In Value is Incorrect")

Thanks,

@_Anish

If you observe your flow…you are checki be cash in in the condition but in the log you are writing about cash out

Please verify all and correct

Cheers

Hello @RajKumar_DC , @Anil_G ,

Thank you guys for your timely response, but please apologies me for not providing the input,

Variables that i declared:

ConvertCashIn= cint(Row(“Cash In”).ToString)
ConvertCashOut= cint(Row(“Cash out”).ToString)

Input:-

Month Cash In Cash out Difference Status
May-15 15 241
Jun-15 77 90
Jul-15 64 44
Aug-15 13K 130
Sep-15 144 78
Oct-15 160 150K
Nov-15 14O 13
Dec-15 33 49
Jan-16 134 169
Feb-16 37K 5K

Expected output:

Month Cash In Cash out Difference Status
May-15 15 241 -226 Correct
Jun-15 77 90 -13 Correct
Jul-15 64 44 20 Correct
Aug-15 13K 130 NA Cash In value is incorrect
Sep-15 144 78 66 Correct
Oct-15 160 150K NA Cash out value is incorrect
Nov-15 14O 13 NA Cash In value is incorrect
Dec-15 33 49 -16 Correct
Jan-16 134 169 -35 Correct
Feb-16 37K 5K NA Both the values are incorrect

Question/Doubt:

if i use the below condition, i’m getting the expected output,
when i give the below in 1st IF condition.
Not IsNumeric(Row(“Cash In”).ToString) And Not IsNumeric(Row(“Cash out”).ToString)

and in 2nd IF condition as,

Int32.TryParse(Row(“Cash In”).ToString,0)

RATHER THAN, if i use the below condition which here is used the variable (ConvertCashIn) instead of column name directly (Row(“Cash In”).ToString),

not IsNumeric(ConvertCashIn) And Not IsNumeric(ConvertCashOut)

Int32.TryParse(ConvertCashIn.ToString, 0)

i’m getting either result as only cash out is incorrect,

Month Cash In Cash out Difference Status
May-15 15 241 -226 Correct
Jun-15 77 90 -13 Correct
Jul-15 64 44 20 Correct
Aug-15 13K 130 NA Cash out value is incorrect
Sep-15 144 78 66 Correct
Oct-15 160 150K NA Cash out value is incorrect
Nov-15 14O 13 NA Cash out value is incorrect
Dec-15 33 49 -16 Correct
Jan-16 134 169 -35 Correct
Feb-16 37K 5K NA Cash out value is incorrect

OR Cash In is incorrect though after changing the assign values

Month Cash In Cash out Difference Status
May-15 15 241 -226 Correct
Jun-15 77 90 -13 Correct
Jul-15 64 44 20 Correct
Aug-15 13K 130 NA Cash In value is incorrect
Sep-15 144 78 66 Correct
Oct-15 160 150K NA Cash In value is incorrect
Nov-15 14O 13 NA Cash In value is incorrect
Dec-15 33 49 -16 Correct
Jan-16 134 169 -35 Correct
Feb-16 37K 5K NA Cash In value is incorrect

Also, @RajKumar_DC , possible can you correct me the way i understand your code and mention first as “You Got it!” in next reply :slight_smile:

If(IsNumeric(Row(“Cash In”).ToString),If(IsNumeric(Row(“Cash Out”).ToString),“Correct”,“Cash Out Value is Incorrect”),“Cash In Value is Incorrect”)

If(IsNumeric(Row(“Cash In”).ToString)–> is true then it takes “Correct”,“Cash Out Value is Incorrect”) and comes out of lf… then, next time if this fails, it goes to below condition

If(IsNumeric(Row(“Cash Out”).ToString)–>is true then it takes ,“Cash In Value is Incorrect”)

Thanks,

@_Anish

When cashin try prae is pass as per the then block you have written cash out…and in else cash in…but it should be reverse…and also …one more condition is to be there to check cashout value as well…becayse that also can be non numeric alone

Cheers

Hi @Anil_G,

First you need to check “Cash In” and “Cash out” both are as an Integer or not if its integer then get both column sum value update it in Difference column. check attached Xaml

Workflow

Xaml
Sequence6.xaml (9.4 KB)

Thanks,

@RajKumar_DC ,

Actually those things i’ve done and getting the correct results, i’m using Try catch and in TRY it checks if the cash in and out values matches then updating to DT will happen, if it fails then it will check whether cash in or out has non numeric(i,e) able to parse or not in CATCH section.

please do me a favor, so you can get my point.

Declare a variable and assign Row(“Cash In”).tostring to it same like “Cash out” too. And use that variable in the nested if condition like below and let me know you are getting the correct results.

Actually this was my question. The thing is if i use Row(“Cash In”).tostring in any condition i’m getting the expected results 100%.

But if i declare this Row(“Cash In”).tostring in a variable and then if i use in any IF condition i’m getting wrong results.

Since i’m new user, it’s not allowing me to upload the xml file, so creating miscommunication i hope. Also, i thank you both for the patience :slight_smile: .

Thanks

Got the answer i hope,

it’s getting faulted when i use the declared variable in IF condition, since parsing getting failed in either cash in or cash out assign value in try section and directed to catch block, from here in next iteration the cash in or cash out value not getting updated, so the condition result me always fails and result me either only true or only false… instead if i use the statement as Row(“cash in”). tostring the DT value comes into catch and validated then result me the correct solution(i,e) only cash in value incorrect or cash out value is incorrect or both are not correct.

the motive of writing this will help me for future reference or anyone might get different idea by reading this post.

special thanks to @RajKumar_DC and @Anil_G :full_moon_with_face: