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
Solved! Go to Solution.
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:
Please have a try, I hope it can help you.
Best Regards,
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.
You declared variables('Revenue') as float, right?
Your expression is valid for int variables
Hope this helps
Proud to be a Flownaut!
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
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
Proud to be a Flownaut!
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
Hi again
Have you tried to convert whatever 'number as string' you receive to float? I mean before adding the $ sign.
Hope this helps
Proud to be a Flownaut!
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
Proud to be a Flownaut!
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
Happy Flowing!
Proud to be a Flownaut!
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
I guess @degvalentine is the right contact person for your question
Hope this helps
Proud to be a Flownaut!
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:
Please have a try, I hope it can help you.
Best Regards,
@ 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
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.
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
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/
If you have a string value you might need to cast it first using "float()".
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
39 | |
36 | |
34 | |
32 | |
27 |
User | Count |
---|---|
45 | |
36 | |
33 | |
25 | |
22 |