cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User
Super User

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

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
Highlighted
Super User
Super User

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

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

Highlighted
Community Support
Community Support

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

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.

Highlighted
Helper II
Helper II

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

@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.

Highlighted
Community Support
Community Support

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

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.

Highlighted
Helper II
Helper II

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

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

Helpful resources

Announcements
firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (6,899)