Initialize an integer variable to 12305

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

 

Initialize an integer variable to 12305

 

To convert the number into currency data I’m using the Compose action.

Concat function in 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

By Pieter Veenstra

Business Applications and Office Apps & Services Microsoft MVP working as a Microsoft Productivity Principal Consultant at HybrIT Services. You can contact me using contact@veenstra.me.uk.

2 thoughts on “Microsoft Flow – Create currency output”
  1. Lets consider following case
    62699333.739999
    how to bring following result.above code not working for this case

    $62,699,333.74

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.