cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Converting a decimal number that is stored as a strong to an int or currency

Hello,

 

I am trying to convert a decimal number (Ex: 1234.1) that is stored as a string in a CDS field to an integer or currency value to store in a currency field. 

 

I used the int() to convert and i had no issue if the value is without a decimal like 1234 however the int() fails when it has decimal value like 1234.1 . The error message i get is :

Unable to process template language expressions in action 'Create_New_WBC' inputs at line '1' and column '44099': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'.

 

My flow action where i am using the int()

Int Function Flow 1.png

Any suggestions on how i can convert this string to an integer or a currency? Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Hi @Nithin_Vanam 

 

Try following expression :

 

if(contains(string(outputs('decimalnumber')),'.'),split(string(outputs('decimalnumber')),'.')[0],outputs('decimalnumber'))
 
(outputs('decimalnumber') is my variable that contain number (decimal or non decimal) replace this with your variable or field.
 
 
-------------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
 
 

View solution in original post

5 REPLIES 5
Super User
Super User

Hi @Nithin_Vanam 

 

Try following expression :

 

if(contains(string(outputs('decimalnumber')),'.'),split(string(outputs('decimalnumber')),'.')[0],outputs('decimalnumber'))
 
(outputs('decimalnumber') is my variable that contain number (decimal or non decimal) replace this with your variable or field.
 
 
-------------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
 
 

View solution in original post

Community Support
Community Support

Hi @Nithin_Vanam

 

Do you want to keep the integer part of the string and discard the fractional part of this value? Such as format the string  1234.1 to 1234 and then save the 1234 to the int or currency field, if yes, @DeepakS 's solution should work for you.

 

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@DeepakS , that worked like a charm. Thank you for that.

 

@v-alzhan-msft : Is there any way i could retain the value after the decimal? For ex convert a string of "1234.5" to a numeric value of 1234.5 ?

 

Thanks for all the help.

Hi @Nithin_Vanam ,

 

I kwon we could add the Number of decimal places for a Number/Currency type column in sharepoint, and then we could add the value with decimal in the column.

Maybe you could take a try.

1.png

Best Regards,

Alice

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the suggestion. Will give it a go later. 

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (59,493)