Convert UI element to 1 Decimal Place

Hi,

I have the following UI Element as shown in the Excel below:

I need to cross-check it with my Excel and if it matches then perform certain action.
I can convert my values in Excel to 1 decimal place:

I can also extract the numbers only from the UI element as solved by @prasath17 here:

Now I need to convert the UI element to 1 decimal place. That is I am using a “Get Text” activity and after trimming to get the Number only, I then need to convert it to 1 decimal place in order to cross-check it with my Excel.
image
Can someone help please?
Thanks!

Hi @Yudhisteer_Chintaram1
try like this

after getting the value using get text , and storing in a string,

use the below assign activity to round off

let say you had stored the get text result in input variable

assign activity

input = Math.Round(CDbl(input),1).ToString

This will round the number to 1 decimal places

Hope it helps

Regards,
Nived N
Happy Automation

1 Like

Thanks man!

1 Like

@NIVED_NAMBIAR
The problem I am experiencing now is that sometimes the UI element is like this:
image

But in my Excel the value is 1.0
So it does not match. Can we transform this number to 1 dp?
That is if we have the 7.32 in the UI element, it goes to 7.3 with your code.
But if we have 1 in the UI element, it gets transform to 1.0

Can we have that?

Hi @NIVED_NAMBIAR ,

It is not working if my value is “1.032”.
Or any value that has a zero after the decimal point, it is returning an integer.
image
image

image

@Yudhisteer_Chintaram1 - could you please let us know what are the different values and the output you are looking for?

1 Like

Thanks for the help @prasath17
I tried this process:

I used an if condition to check if the UI element is in decimal place(Contains(".") or integer and convert it to 1 decimal place in both situations. It works fine with any numbers except if I have a number like “1.0” or “2.0434”, that is any number “x.0xxx”.
There it fails as it returns an integer (for ex: 2 instead of 2.0).

I am expecting something like that:

@Yudhisteer_Chintaram1 - Please try this…

Math.round(cdbl(Item),2).ToString(“N1”))

image

Hope this helps…Actually clue was in your previous post, i have posted the reference link from Microsoft docs too…

1 Like

Yep. I tried this one:

Thanks @prasath17

1 Like

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