Rounding in Azure Data Factory
1 min readMar 4, 2022
I encountered a situation recently where I needed to round to whole numbers in an Azure Data Factory pipeline and couldn’t find a built-in function for that purpose. So if you are like me and need a solution, I’ve included examples below for rounding up and rounding down. In these examples, we are wanting to round the result of 10654 / 100 to a whole number.
Rounding Up (107 is desired result):
@add(int(first(split(string(div(10654, 100)), '.'))), 1)
- Divide the two numbers. (Result: 106.54)
- Convert the result from Step 1 into a string. (Result: ‘106.54’)
- Split the string into an array at the decimal. (Result: [‘106’, ‘54’])
- Take the first item from that array. (Result: ‘106’)
- Convert the result from Step 4 into an integer. (Result: 106)
- Add one to the result from Step 5 (Result: 107)
Rounding Down (106 is desired result):
@int(first(split(string(div(10654, 100)), '.')))
- Repeat steps 1–5 from above. Step 6 is not needed.
And that’s it.
Hope this was helpful for you. Thanks for reading!