cancel
Showing results for
Did you mean:
Impactful Individual

## Convert string to currency

I found a couple posts on this but nothing that is working for me.

I have a variable of a number like 348749879

I use a compose of:

concat('\$',div(variables('Revenue'),100),'.',if(less(mod(variables('Revenue'),100),10),concat('0',mod(variables('Revenue'),100)),mod(variables('Revenue'),100)))

but this returns: \$3487498.79.79

I think the formula I am trying assumes there is a cents listed.

In my case the number could be 1234 or 1234.56 or 1234.5

I would like them to show as: \$1,234.00 or \$1,234.56 or \$1,234.50

Does anyone have a formula that accomplishes this already?

Thanks,

Terry

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support

Hi @Mattw112IG ,

You can create an Excel file online in SharePoint, like this:

Then create a flow to update the excel file using the function DOLLAR:

=DOLLAR(Number,2)

After that, create get a row to get the converted number.

This is a screenshot of the successful result:

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Kudo Collector

Challenge accepted!

I expanded my absurd expression to include values under 1 trillion and posted it to Format number with thousands separator in Flow email, where I originally put my solution.

15 REPLIES 15
Super User

You declared variables('Revenue') as float, right?

Your expression is valid for int variables

Hope this helps

Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Impactful Individual

Thanks,

Even in your tests though it looks like it takes the last two digits and makes them cents instead of dollars??

I just added a compose to mine: int(<the revenue number>)

But the formula turned 40000 into \$400.00

The last two digits should not be turned into cents??

Thanks,

Terry

Super User

Terry

Not sure I understood you. I mean, in your expression you are dividing the content of variable Revenue by 100. That's the reason why it takes the last two digits and makes them cents instead of dollar

Hope this helps

Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Impactful Individual

Right, I don't want that and need a formula that handles all the situations I mentioned (no cents, cents, one digit of cents).  Was hoping someone already had one.

Thanks,

Terry

Super User

Hi again

Have you tried to convert whatever 'number as string' you receive to float? I mean before adding the \$ sign.

Hope this helps

Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Super User

I have created an array for testing purposes, 3 string items with the 3 different formats you mentioned before

Once the array is initialized, I apply the following expression

`createArray(concat('\$',float(variables('ArrayOfNumbersAsStrings')[0])),concat('\$',float(variables('ArrayOfNumbersAsStrings')[1])),concat('\$',float(variables('ArrayOfNumbersAsStrings')[2])))`

Hope this helps

Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Super User

Hi again

If you need also the comma, in the following post tyou will find an expression to format a float less than 1 million into a string for currency (not including the dollar symbol) with a thousands separator and 2 digits after the decimal. I haven't tested myself, but it received 4 kudos, so I guess several people find it extremely useful

https://powerusers.microsoft.com/t5/Using-Flows/Format-number-with-thousands-separator-in-Flow-email...

Happy Flowing!

Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Impactful Individual

Thanks.  I followed the link to your other post and used that code and it works great up to \$999,999.99...

I've tried disecting the formula and my eyes are getting cross eyed 😉

How do I make this handle up to \$999,999,999.99

I would think I would just need to add one more section like the one below after the last one?  But how would it know where to start?

```    concat(
substring(
string(variables('myFloat')),
0,
max(0, sub(length(first(split(string(variables('myFloat')), '.'))), 3))
),
',',
substring(
first(split(string(variables('myFloat')), '.')),
max(0, sub(length(first(split(string(variables('myFloat')), '.'))), 3)),
min(3, length(first(split(string(variables('myFloat')), '.'))))
)
),```

or is it simplier than that and just need to change the 3's to 6's? or something?

Thanks,

Terry

Super User

I guess @degvalentine is the right contact person for your question

Hope this helps

Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Community Support

Hi @Mattw112IG ,

You can create an Excel file online in SharePoint, like this:

Then create a flow to update the excel file using the function DOLLAR:

=DOLLAR(Number,2)

After that, create get a row to get the converted number.

This is a screenshot of the successful result:

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Impactful Individual

@ v-bacao-msft, thanks this works for me.  Would be nic eif I could just do it all self contained within the flow but works for now.

@efialttes,@degvalentine - thanks.  I would prefer to use your formula but needs to support over a million.

Thanks,

Terry

Kudo Collector

Challenge accepted!

I expanded my absurd expression to include values under 1 trillion and posted it to Format number with thousands separator in Flow email, where I originally put my solution.

Impactful Individual

I am having an error with the code you did.

When I have a record that has "0" in the field to pass to your formula then I get the error:

"InvalidTemplate. Unable to process template language expressions in action 'Compose_-_Dif' inputs at line '1' and column '2623': 'The template language function 'substring' parameters are out of range: 'start index' and 'length' must be non-negative integers and their sum must be no larger than the length of the string. Please see https://aka.ms/logicexpressions#substring for usage details.'."

Does this mean your formula is expecting a certain # of characters?

THanks,

Terry

Kudo Collector

Thanks, @Mattw112IG. I posted a fix on the source thread.

Kudo Collector

Please be aware that Flow added the formatNumber function! A locale-specific solution with commas and rounding is easy.

``formatNumber(1234.567, 'N', 'en-US')``

https://flow.microsoft.com/en-us/blog/simplified-number-formatting/

https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#the-curr...

If you have a string value you might need to cast it first using "float()".

Announcements

#### Launching new user group features

Learn how to create your own user groups today!

#### Community & How To Videos

Check out the new Power Platform Community Connections gallery!

#### Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,030)