Good afternoon,
I've run into some issues with the function int() while trying to convert a decimal number to an int.
Here's my example:
I have an entity on CDS that has a field called "price" that is stored as a decimal number.
However, simply calling int() on that field throws an error, specifically "Unable to process template language expressions in action 'Compose_2' inputs at line '1' and column '2595': 'The template language function 'int' was invoked with a parameter that is not valid. The value cannot be converted to the target type.'."
I've tried to make the decimal a string and then convert, but that fails with a similar message.
An example price would be 2819.23. I believe the issue is contained within the int() function but would love to hear any suggestions. Thank you!
Solved! Go to Solution.
If you review the Wokflow Definition Language documentation for Integer, please notice that int() requires a string:
int Return the integer version for a string. int('<value>')
So, your option is only really to "float" the decimal places via a variable or action. If the float value is in a variable:
substring(string(variables('VARIABLE_NAME')),0,add(indexof(string(variables('VARIABLE_NAME')),'.'),3))
If the float value is in an action:
substring(actionOutputs('ACTION_NAME'),0,add(indexof(actionOutputs('ACTION_NAME'),'.'),3))
Please see this previous post by @gamoraes that explains the process in further detail. There is also a Currency and decimal format in Microsoft Flows idea currently "Under Review" that you may vote or comment on.
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
If you review the Wokflow Definition Language documentation for Integer, please notice that int() requires a string:
int Return the integer version for a string. int('<value>')
So, your option is only really to "float" the decimal places via a variable or action. If the float value is in a variable:
substring(string(variables('VARIABLE_NAME')),0,add(indexof(string(variables('VARIABLE_NAME')),'.'),3))
If the float value is in an action:
substring(actionOutputs('ACTION_NAME'),0,add(indexof(actionOutputs('ACTION_NAME'),'.'),3))
Please see this previous post by @gamoraes that explains the process in further detail. There is also a Currency and decimal format in Microsoft Flows idea currently "Under Review" that you may vote or comment on.
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Hi @jonathan_rou ,
As you said, the price is float not integer.
So please take the float() for a try.
For more 'Conversion functions', please take a reference :
Best Regards,
Community Support Team _ Zhongys
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This code segment: substring(string(variables('VARIABLE_NAME')),0,add(indexof(string(variables('VARIABLE_NAME')),'.'),0)) worked to remove the decimal places from the decimal number.
Thank you for your help.
Using the format number action makes converting the float/decimal to string easy then you just give its output to int()
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
45 | |
42 | |
36 | |
36 | |
22 |
User | Count |
---|---|
41 | |
31 | |
29 | |
28 | |
26 |