Microsoft Flow – Create currency output

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)))

Advertisements


Categories:Flow, Microsoft Flow, Office 365

Tags:

Please leave a comment or feedback

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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

%d bloggers like this: