This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
on 09-23-201602:00 PM - edited on 03-12-202011:02 AM by AYXAcademy
Whether for mathematical or formatting purposes, you may want to round your numeric data. Depending on the type of rounding you're looking to do, Alteryx has a solution for you!
To demonstrate rounding methods, we’ll use some sample data for distances that a truck traveled between two locations ([Total Distance]). As you can see, the data includes 11 values after the decimal point. That level of precision is probably unnecessary for our analyses. So, to better represent this data, let's 1) round it to the nearest mile, 2) round to the nearest 100 miles, 3) round to two decimal places and 4) round it up to the nearest mile.
1) Round to the nearest mile (integer):
The current data reflects the distance a truck traveled from one location to another. We want to round this data to the nearest mile. To do this, we’ll use the Round function (found under the Math category of functions in the Formula Tool). The Round function requires two parameters: the data you want to round, and the multiplier to which you want to round. In the case of rounding to the nearest integer, we will simply round to the nearest multiple of 1.
2) Round to Nearest 100 miles
If, say, we wanted to round to the nearest 100 miles, we’d simply adjust the multiplier to 100:
3) Round to Two Decimal Places:
If we needed to round to a certain number of decimal places (let’s say 2 decimal places*), we can change the multiplier to 0.01 :
*Note that the data type has been set to Double for accommodating decimal places in the rounded results.
4) Round-Up to the Nearest Mile (Integer):
You may find yourself with the need to round up (not necessarily to the nearest integer). In this case, we’ll need to turn to the Ceil function (also under the Math category of functions). The Ceil function will return the smallest integer greater than or equal to a value [x] or expression [Value]/[x]. So, to use an example from the sample data, Truck 1 traveled 567.712005 miles. To round up to the nearest mile, we’ll use the expression CEIL([Total Distance]/1) Because 567.712005 divided by 1 is itself, the smallest integer that is greater than or equal to 567.712005 is 568.