How to convert generic value type to decimal type in uipath

How to convert generic value datatype to decimal datatype in uipath

Hi Mohammed,

you can use this expression: Convert.ToDecimal(GenericVar.ToString) where GenericVar is your variable of GenericValue datatype.

Happy automating

I have tried this syntax and its not working.Please suggest different method.

Thanks,
Nawaz.

Hi

Give a try with this
dec_vatiable = Convert.ToDecimal(Convert.ToInt32(Gen_variable.ToString))

Or

Try with

dob_variable = Convert.ToDouble(Gen_variable.ToString)

Or

If the generic value has some minus symbol at front then try with this

dec_variable = If(gen_variable.ToString.Contains(“-“), “-“+Convert.ToDecimal(gen_variable.ToString.Replace(“-“,””).ToString), Convert.ToDecimal(gen_variable.ToString))

Cheers @Mohammed_Nawazuddin

we guess that the question is related to your other topic

ensure that the value of the GenericValue Variable is a valid number string. Could it be the case that it is tried to convert a value like “20.48 %”? Maybe you can share some sample values with us.

grafik
Series shows that % let fail, but - for negative values will not harm

Also have a look on your other topic as an prototype was shared which is doing the initial case task (Conversion and sorting)

1 Like

Double IS decimal.

Hi Peter,

Thanks for your response, Its related to sort datatable other topic, but some inew issues are coming up and unable to proceed further. It would be helpful if you can provide me Just one scenario on how to convert generic value to decimal type.Let me provide screenshots for reference.
DT1 is the datatable where I am having whole data


With Val3 variable is generic value variable I am didivding it to decimal and then percentage format by format value

With if condition I am checking for above 10% and I am able to capture it in excel. But befor capturing in excel want to sort the datatable as descending order format.
It would be helpful if any suggestions

Thanks,
Nawaz.

please let us do one thing
focus only on one topic. As we have progressed more on this thread:

so lets stay there and finalize it

Thanks