9 Replies Latest reply: Dec 3, 2014 9:44 AM by saurabh singh

# How can I round a number in a graph?

HI Experts!

How can I round a number in a graph?

Jan

• ###### Re: How can I round a number in a graph?

Hi Jan,

Adjusting the formatcode you have in your example will round the number accordingly, have a look at QV manual for more on the formats (page 494) you can set

hope that helps

Joe

• ###### Re: How can I round a number in a graph?

Hi Jan,

You can use the Num() function which takes 2 parameters.

Second parameter can be used to round the result in the second parameter.

Eg. num((22/7), '#,##0.00')   Returns 3.14

Hope it helps !

Cheers !

• ###### Re: How can I round a number in a graph?

If you want the details to be stored use the NUM() function so that the value in your qlik data model is formatted to the screen in the way you want.

To manipulate the values in your data model just use the round() function. You can even specific an additional parameter that define  the rounding 'bucket'  ...1, 5, 100 etc... , its not just restricted to rounding to integers.

There can be some inconsistency if you round to sub integer decimal values, if you want to round to decimal places like .01 , then best to multiple by (in this case)  100 , round, and then divide by 100.  Due to floating point values explainded in the business discovery blog by HIC

• ###### Re: How can I round a number in a graph?

HI Jonathan

Do I understand this right, I have to use the NUM or round function in the script? I can not round in the settings of my table?

Best

Jan

• ###### Re: How can I round a number in a graph?

You can use the suitable function in your Dimension or expression of a chart.

It can be used in the script as well , If the calculation is happening in the script ..

• ###### Re: How can I round a number in a graph?

You can use both in the script or both in the chart straight table / pivot table . They are not restricted to use within specific areas.

If you use num() in a chart expression for example, just set the  formatting on the 'Number' tab to 'expression default' because they do similar things.  If you round() in the chart expression, the formatting on 'number' will be applied on the result of the round() function.

Also see other post below for rounding up/down with the floor/ceiling functions too.

• ###### Re: How can I round a number in a graph?

What Johnathan is saying is that if you do it in the script, you only have to do it once. If you do it in an expression or in the format code, you have to do it for each graph / chart / table etc.

EDIT - Ninja'd!

• ###### Re: How can I round a number in a graph?

You can use also ceil(X) and floor(X) to force round up or down. It's handy of you want to round a number to multiples of 0.5 etc.

• ###### Re: How can I round a number in a graph?

you can use round() or ceil() function.