How to convert percentage into number

Hi all,
I have a column in excel which is in percentage format, i want to convert it into number format. Is there a way we can do that in data table itself after reading ?

Attaching the initial format (percentage) and required format (number).

Percentage
number

@sachinns

Did you try using format cell or range activity? And format your excel cells iself?

Or

Use a assign activity as below(mostly when you read the excel using read range with raw values or use read range woth workbook…you would get the values as 0.65 or so…check that by reading and checking the datatable if so use as below

Dt.Columns(“columnname”).Expression = "’[Columnname]"

Cheers

@Anil_G It didn’t work for me. Even the expression was throwing me error “Assign: Exception has been thrown by the target of an invocation.”
I tried by adding new column also.

@sachinns

Use a loop and add an apostrophe before the value…and check what is the column type if it is string or not

Currentrow(“columnname”)= “‘“ + currentrow(“columnname”).Tostring

Cheers

@Anil_G It is coming as object.

Used : Dt.Columns(“Columnname”).DataType.ToString

@sachinns

Then you need not change anything…you can try this…it should work…facing any issue?

If so add a column withs tring type and assign the value to that column

Cheers

@Anil_G Can you please give me the workflow for that ? What is the expression to convert from percentage to numbers ?

@sachinns

you need to multiply the row with 100 again and you will get the number format

Hope this may help you

Thanks

@sachinns

Try this

Currentrow(“columnname”)= “‘“ + (Cdbl(currentrow(“columnname”).Tostring)/100).ToString

Cheers

I use this to fix something related to this issue sometimes ago

Currentrow(“columnname”)= “‘“ + (Cdbl(currentrow(“columnname”).Tostring)/100).ToString

Regards.

@Anil_G Thanks. It worked.

@Onyekachi_John Thank you.

1 Like

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