Rounding in Azure Data Factory

Kyle Gibson
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)
  1. Divide the two numbers. (Result: 106.54)
  2. Convert the result from Step 1 into a string. (Result: ‘106.54’)
  3. Split the string into an array at the decimal. (Result: [‘106’, ‘54’])
  4. Take the first item from that array. (Result: ‘106’)
  5. Convert the result from Step 4 into an integer. (Result: 106)
  6. Add one to the result from Step 5 (Result: 107)

Rounding Down (106 is desired result):

@int(first(split(string(div(10654, 100)), '.')))
  1. Repeat steps 1–5 from above. Step 6 is not needed.

And that’s it.

Hope this was helpful for you. Thanks for reading!

--

--

Kyle Gibson
Kyle Gibson

Written by Kyle Gibson

Christian, husband, father. Data Engineer at Chick-fil-A.

No responses yet