Warm tip: This article is reproduced from serverfault.com, please click

How to round off float number to 2 decimal numbers in azure logic apps?

发布于 2019-03-13 03:14:43

In azure logic app I convert kilogram to to pound, I need to round off that result to two decimal numbers.

enter image description here

Expression : mul(float(variables('total_weight')) , 2.20462262185)

Result :  1.102311310925
Expected Result : 1.10
Questioner
Dinuka Wanasinghe
Viewed
0
George Chen 2019-03-13 13:59:06

For now, there is still no generalized rounding solution in Logic Apps. However you need build solutions specific to your data.

Here is an approach you could round decimals to two for display purpose.

if(contains('56789', substring(string(variables('math')),4,1)),substring(string(add(variables('math'),0.01)),0,4),substring(string(variables('math')),0,4))

This way will return the string format, you could add float() to return float number. I test twice with 2.20462262185 and 2.20562262185.

enter image description here

enter image description here

enter image description here