cancel
Showing results for
Did you mean:
Level 8

## 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
Highlighted
Community Support Team

## Re: Convert string to currency

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.
Level: Powered On

## Re: Convert string to currency

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.

14 REPLIES 14
Super User

## Re: Convert string to currency

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

Your expression is valid for int variables

Hope this helps

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Level 8

## Re: Convert string to currency

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

## Re: Convert string to currency

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

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Level 8

## Re: Convert string to currency

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

## Re: Convert string to currency

Hi again

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

Hope this helps

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Super User

## Re: Convert string to currency

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

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Super User

## Re: Convert string to currency

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!

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Level 8

## Re: Convert string to currency

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

## Re: Convert string to currency

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

Hope this helps

If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!

Highlighted
Community Support Team

## Re: Convert string to currency

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.
Level 8

## Re: Convert string to currency

@ 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

Level: Powered On

## Re: Convert string to currency

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.

Level 8

## Re: Convert string to currency

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

Level: Powered On

## Re: Convert string to currency

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

Announcements

#### Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

#### Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

#### Microsoft Learn

Learn how to build the business apps that you need

#### Power Platform World Tour

Find out where you can attend!

#### Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 45 members 4,658 guests
Recent signins: