Today, I tried to convert a number into currency using Microsoft Flow.
For simplicity sake , I have set a variable to the the number 12305, but I want to display this number as $123.05
To convert the number into currency data I’m using the Compose action.
Using an expression like this one:
concat(‘$’,div(variables(‘value’),100),’.’,mod(variables(‘value’),100))
would almost work. for 12345 I will simply end up with $123.45 but if the cents are less than then like in my example of 12305 I will end up with $123.5 which will be confusing.
Therfore I’m having to add somthgin to my expression that can add the leading 0 if the number of cents is less than 5. With a simply if expression I got quite quickly what I needed.
concat(‘$’,div(variables(‘value’),100),’.’,if(less(mod(variables(‘value’),100),10),concat(‘0’,mod(variables(‘value’),100)),mod(variables(‘value’),100)))
If you are happy to use the SharePoint REST API there is an alternative option available. John Liu’s tweet will explain this approach
Lets consider following case
62699333.739999
how to bring following result.above code not working for this case
$62,699,333.74
[…] remember trying to format numbers into a currency format a while back Create currency output, but I was never happy with this […]