I need to round the value of a number that the flow will get from a file property.
What I want is to get this float x.yz and tranform it into x.00 (or an integer).
I have tried to use Int() but it seems it doesn't work.
Solved! Go to Solution.
I wrote a long response, only to lose everything when clicking reply.. 😒
TL;DR (as in too long didn't rewrite):
Still not in expressions:
Both powerapps and power automate desktop has functionality:
Power Automate Desktop:
Yeah I also get these kind of issues myself, normally it saves every so often so you should be able to load in a draft of it, but doesn't always work so I just try to copy it regularly to make sure I still have it.
Anyways it is true that there is a truncate method, but you can round numbers in 3 different ways that truncate method isn't able to do this. Truncate is a round up method, but what about regular rounding or rounding down, this is not available. One would need to implement these simple functionalities themselves instead of being able to focus on the more complex stuff.
Same is for powerapps you are showing canvas applications which indeed provides alot more functionalities, although that this cannot be said for model driven applications. Model driven applications have almost no formalas to be used only things like +, -, /, *, trim, multiple formulas to add or subtract days months etc but that's it. To be able to use rounding functions we literally need to add 3 fields, 1 with the base calculation of type decimal, 1 is an integer (whole number) which is set to the decimal value (so a standard rounding applies) and then the actual field that calculates which value it is supposed to be. But things like modulo, floor, ceil, etc... are just not available.
For example I have a project in my model driven app and I want that every so often a new invoice is being generated, this could be once a year or every 3 or 4 months. So if I want to create an invoice on a certain date, I would need a date field, a field that calculates the current year of the project in decimal form, then that same field in whole number form, to then actually have a different field that calculates how to round the value correctly. So now if its day 10 its year 1, if its day 364 its still year 1, day 365 its year 2 (or something like that its still 1day of but that's okay) this method is so good It's able to calculate in real time what year it is and I have a flow running every day to check which projects need a new invoice based on that field.
I am glad that I was able to even do it this way, even though its not how its supposed to be. If it wasn't possible I don't think that we would be using this system still when something as easy as rounding is blocking yearly invoicing. Even if it is something that could be calculated every day with flow, because there would be too many api requests which would result in flows that no longer work since we reached the maximum amount of api requests within 24h, which I almost reached.
Either way I am hoping that both Powerapps and Power Automate will improve these formulas so the most basic of things can be done without running against any limits (which there are too many of).
Can't wait to see those improvements!
Thanks in advance,
I also would like to see rounding functions in expressions (Power Automate).
I came up with this kind of workaround for rounding up a number after division with integers:
if( greater( mod( num1, num2 ), 0 ), add( div( num1, num2 ), 1), div( num1, num2 ) )
Basically, when dividing two integers (num1/num2), if there is a remainder greater than 0, add one to the result to round it up to the next integer.
Thank you for providing this expression - it helped me at least complete a flow that I was struggling with because I was trying to run a calculation expression with numbers stored as text (from SharePoint form) in both integer and floating decimal type numbers. I figured out how to convert the text numbers to string format and used this expression on 3 fields to convert to integer and calculate a sum of those 3 fields.
The only problem is that this approach effectively rounds down to the whole number for floating decimal values which results in a very slight under-reporting in the total calculation and ideally we could convert everything to float so we could calculate a more accurate total.
Is there an inverse to this expression that would change integer data (i.e. 3) into a floating decimal value (i.e. 3.00) so that a more accurate total could be calculated?
If not, is there another approach that would could recommend exploring?
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.