Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
Further to this, our requirements are to only apply this to numbers less than one, i.e.:
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')
))))
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?
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)))
Thanks Anil and Jonathan for your swift response.
Here is an example of what I am trying to achieve:
Chemical | Value | Round(Value, 0.001) | Round Value to 3 Sig Figures |
apples | 742,396 | 742,396.000 | 742000 |
oranges | 0.07284 | 0.073 | 0.728 |
bananas | 231.45 | 231.450 | 231 |
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
Further to this, our requirements are to only apply this to numbers less than one, i.e.:
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')
))))
Thanks chanty4u, but I don't think the QlikView Round() function behaves that way?
Even I haven't checked . Is issue resolved ?
No worries.
Yes I have resolved using my workaround code above. But happy to take on any suggestions for improvement.
good to hear cool.