Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I round a number in a graph?

HI Experts!

How can I round a number in a graph?

ScreenShot147.jpg

Thank you for your help!

Jan

1 Solution

Accepted Solutions
JonnyPoole
Employee
Employee

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

View solution in original post

9 Replies
Not applicable
Author

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

Not applicable
Author

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 !

JonnyPoole
Employee
Employee

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

ThornOfCrowns
Specialist II
Specialist II

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.

Not applicable
Author

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

Not applicable
Author

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 ..

JonnyPoole
Employee
Employee

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.

ThornOfCrowns
Specialist II
Specialist II

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!

saurabh5
Creator II
Creator II

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