Round numbers

Still need help?

The Atlassian Community is here for you.

Ask the community

The Formula column” and “Apply formula” steps allow you to perform functions on your data, including our custom functions, standard SQLite functions, and the following math functions: DEGREES(), RADIANS(), COS(), SIN(), TAN(), COSH(), SINH(), TANH(), EXP(), LOG(), LOG10(), SQRT(), CEIL(), FLOOR()

Check out the full list of SQLite functions to see what other transformations are possible.

Round function

If you’re performing a calculation on your data, you’ll often need to round the resulting numbers, which you can do using the ROUND function.

With your chart open in Visual SQL, select “Formula column” above the Result table, select the Custom formula type, and use the following formula:

ROUND("Column Name", 2)

where “Column Name” is the name of the column you’d like to round, and 2 is the number of decimal points you’d like to round up to in your column.


If you’re performing a calculation on integers, then only integers will be returned. If you want your results to have decimal precision, you’ll need to convert your values to decimals before performing any calculations.

You can do this by using the “Apply formula” step. Choose Custom as the formula type and multiply your formula numerator by 1.0. For example:

(1.0 * "Column 1")/"Column 2"

Multiplying “Column 1” by 1.0 will force the value to be converted to the data type “real” and show decimal precision.

You can also do this directly within the ROUND function as shown in the example below:

ROUND(1.0 * "Column 1" / "Column 2", 2)


Casting the column as an integer

If you want to remove all decimals from your values, you can also use the CAST function to cast your column as an integer. This will convert all the values into whole numbers.

Adding either a “Formula column” or “Apply formula” step, use a Custom formula and enter the following formula:

CAST("Column Name" AS int)

where “Column Name” is the name of your original column.

This doesn’t round to the nearest whole number; it simply removes the decimal point and its trailing numbers.


Last modified on Oct 27, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.