Hi - Is there any way to adjust the rounding in Go...
# gooddata-platform
m
Hi - Is there any way to adjust the rounding in Good Data? For example, I have a number of 50.495%, which is getting rounded down to 50%. However, most other tools I'm using rounds this UP to 51%. Is there any way to adjust this so that rounding is consistent?
update: I tried using the round function to round to 3 decimal points (since the numbers are percentages, they are actually 0.50495). However, this isn't applying rounding and instead working like a truncation. Doing a round,3 makes the number 0.504 (I would expect it to be .505).
i
Hi Mitchel, Sorry to hear the ROUND function didn’t do the trick. Please check also our articles about number formatting linked below: General formatting Formatting numbers in Insights
m
@Ivana Gasparekova - I guess I am confused because the documentation does say that the number would be rounded up: https://help.gooddata.com/doc/growth/en/dashboards-and-insights/maql-analytical-query[…]e/numeric-functions/rounding-and-truncation-functions/round/
Why wouldn't ROUND(percentage,3) turn 0.50495 into 0.505?
Really just asking out of curiosity... it seems that Google Sheets rounds exactly the same way
t
Hello @Mitchel Roling, are you sure about the provided values? I have checked the results with a dummy metric and it seems to work correctly.
Also if not mistaken, I believe 50.495% should not get rounded to 51% unless you are doing double rounding as I did on the example above. I rounded 0.50495 into 0.505 using MAQL and then I rounded the results again using metric formatting. That’s why the UI on the screenshot displays 0.51.
2
m
@Tomas Muchka - My apologies. There were actually two numbers in the table next to each other: .50495 and .504438. I mixed the two up. As for rounding in general, I agree that 50.495 should get rounded to 50%, but I have a client who strongly disagrees 🙂. Trying to find a way to appease. Appreciate that you looked into it and apologies for my own mix-up.
i
No worries about that at all, we are glad it got sorted out. 😉
t
Thank you @Mitchel Roling for the explanation. MAQL does not support ROUND UP out of the box, but you can quite easily mimic the behaviour using CEILING() function. The idea is to move the decimal point to where you want to round up, do round up and move it back. In our case it would be:
Copy code
select CEILING(0.50495*100)/100
which then results into 0.51 and thus 51%.
🙌 1
m
@Tomas Muchka Yeah, I see there is definitely a solution. Ceiling doesn't work because the client would round 50.4438 DOWN. But double-rounding (adding a round function to 3 decimal places with a second rounding in the formatting) does seem to work. Thanks again!
t
That’s weird. Ceiling should always round an input value to the nearest integer that is greater than it. https://help.gooddata.com/doc/growth/en/dashboards-and-insights/maql-analytical-query[…]numeric-functions/rounding-and-truncation-functions/ceiling/
m
Yes, but the client doesn't always want it to round up
The clients wants a number like 50.4438 to be rounded DOWN, but the ceiling function would always round a number like this up
They essentially go through multiple rounds of rounding: 50.4438 50.444 50.44 50.4 50
t
m
Yes, but a number like .50495 should be rounded UP
.50495 .5050 .505 .51
If I wrap enough round functions around the number, it also goes through these steps.
👍 1