Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
michelle_le
Partner - Contributor III
Partner - Contributor III

Rounding to 3 Significant Figures

Hi Team

I am looking for some guidance on how to round numbers to 3 Significant Figures?

We are calculating Averages of chemical readings, and using a rounding to 3 decimal places is not ideal for this particular use case.

Thanks in advance!
Michelle

1 Solution

Accepted Solutions
michelle_le
Partner - Contributor III
Partner - Contributor III
Author

Further to this, our requirements are to only apply this to numbers less than one, i.e.:

  • Between 0-1.......Round to 3 significant figures.
  • Greater than 1....Round(Value, '0.001')

Based on this, I have come up with the following method and currently testing. Let me know if someone comes up with a smarter way

If(Avg(VALUE) >=1, Round(Avg(VALUE), '0.001'),
Round(Avg(VALUE), 1/(Pow(10,3+
SubstringCount(TextBetween(Avg(VALUE),'.',Left(Num(TextBetween(Avg(VALUE), '.', Null())),1)),'0')
))))

View solution in original post

9 Replies
Anil_Babu_Samineni

You may describe more with screen shots.

As i understand, you need something like after decimal you want to print 3 number format or what?

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
jonathandienst
Partner - Champion III
Partner - Champion III

3 Decimal places:

Round off

=Round(Value, 0.001)

Round up

=Ceil(Value, 0.001)

Round down

=Floor(Value, 0.001)

3 significant digits:

=Round(Value, Pow(10, Floor(Log10(Value) - 2)))

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
michelle_le
Partner - Contributor III
Partner - Contributor III
Author

Thanks Anil and Jonathan for your swift response.

Here is an example of what I am trying to achieve:

   

ChemicalValueRound(Value, 0.001)Round Value to 3 Sig Figures
apples742,396742,396.000742000
oranges0.072840.0730.728
bananas231.45231.450231

You'll note that depending on the value, we only want to round to 3 significant figures, not 3 decimal places.

Some further context to Sig.Figs. as described here: Rounding and Significant Digits | Purplemath

Thanks

Michelle

michelle_le
Partner - Contributor III
Partner - Contributor III
Author

Further to this, our requirements are to only apply this to numbers less than one, i.e.:

  • Between 0-1.......Round to 3 significant figures.
  • Greater than 1....Round(Value, '0.001')

Based on this, I have come up with the following method and currently testing. Let me know if someone comes up with a smarter way

If(Avg(VALUE) >=1, Round(Avg(VALUE), '0.001'),
Round(Avg(VALUE), 1/(Pow(10,3+
SubstringCount(TextBetween(Avg(VALUE),'.',Left(Num(TextBetween(Avg(VALUE), '.', Null())),1)),'0')
))))

Chanty4u
MVP
MVP

Hi,

Did you tried this?

=ROUND(1234567,-6) = 1000000 // 1 sig. digit
=ROUND(1234567,-5) = 1200000 // 2 sig. digits
=ROUND(1234567,-4) = 1230000 // 3 sig. digits
=ROUND(1234567,-3) = 1235000 // 4 sig. digits
michelle_le
Partner - Contributor III
Partner - Contributor III
Author

Thanks chanty4u‌, but I don't think the QlikView Round() function behaves that way?

Chanty4u
MVP
MVP

Even I haven't checked . Is issue resolved ?

michelle_le
Partner - Contributor III
Partner - Contributor III
Author

No worries.

Yes I have resolved using my workaround code above. But happy to take on any suggestions for improvement.

Chanty4u
MVP
MVP

good to hear cool.