Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

wendyharrison
New Contributor II

How do I round all calculations to 2 decimal places

Hi,

Please could someone help as I have tried everything I can think of.

I am working in Qlik Sense with lots of data.

Unfortunately Qlik Sense is calculating my results by several decimal places and this is having a knock on effect to my overall calculations.

For example one of my calculations is 21.74 * 10.94 which should equal 237.84

Qlik Sense is calculating it as 21.7434736842105 * 10.94 giving me a result of 237.87

Please could someone advise how I get Qlik Sense to do all my calculations at 2 decimal spaces.

Many Thanks

Kind Regards

Wendy

4 Replies
MVP
MVP

Re: How do I round all calculations to 2 decimal places

Hi Wendy,

All calculations are always performed at the maximum available precision, unless you round your numbers manually. So, basically you have 2 options:

1. Round the numbers during the data load:

     LOAD

     ...

     round(Price, 0.01) as Price,     // rounding

     ceil(Qty, 0.01)        as Qty,       // rounding up

...

2. Round the numbers in each calculation within each measure:

   round(Price, 0.01) * round(Qty, 0.01)

or

   ceil(Price, 0.01) * ceil (Qty, 0.01)

Cheers,

Oleg Troyansky

Upgrade your Qlik skills at the Masters Summit for Qlik - coming to Boston, MA this October!

MVP
MVP

Re: How do I round all calculations to 2 decimal places

It is very common for many tools like Qlik Sense to use full precision on calculations.

However if you want to do rounding (use fewer decimal places) during calculations you could use the Round() function like this:

Round( Round( 21.7434736842105 , 0.01 ) * 10.94 , 0.01)

Which will give you 237.84

Round - script and chart function ‒ Qlik Sense

passionate
Valued Contributor

Re: How do I round all calculations to 2 decimal places

Try Using:

=num(Yourcaluculation,'#,##')

wendyharrison
New Contributor II

Re: How do I round all calculations to 2 decimal places

Thank you Petter,

This works perfectly.

Kind Regards

Wendy