Hi - Is there any way to adjust the rounding in Go...

# gooddata-platformm

Mitchel Roling

06/28/2023, 7:57 PMHi - 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?

Mitchel Roling

06/28/2023, 8:13 PMupdate: 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

Ivana Gasparekova

06/28/2023, 8:15 PMHi 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

Mitchel Roling

06/28/2023, 8:23 PMMitchel Roling

06/28/2023, 8:24 PMWhy wouldn't ROUND(percentage,3) turn 0.50495 into 0.505?

Mitchel Roling

06/28/2023, 9:08 PMReally just asking out of curiosity... it seems that Google Sheets rounds exactly the same way

t

Tomas Muchka

06/28/2023, 9:33 PMHello **@Mitchel Roling**, are you sure about the provided values? I have checked the results with a dummy metric and it seems to work correctly.

Tomas Muchka

06/28/2023, 9:51 PMAlso 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

Mitchel Roling

06/29/2023, 2:52 AMi

Ivana Gasparekova

06/29/2023, 5:01 AMNo worries about that at all, we are glad it got sorted out. 😉

t

Tomas Muchka

06/29/2023, 7:27 AMThank 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

Mitchel Roling

06/29/2023, 2:14 PMt

Tomas Muchka

06/29/2023, 2:36 PMThat’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

Mitchel Roling

06/29/2023, 2:37 PMYes, but the client doesn't always want it to round up

Mitchel Roling

06/29/2023, 2:37 PMThe clients wants a number like 50.4438 to be rounded DOWN, but the ceiling function would always round a number like this up

Mitchel Roling

06/29/2023, 2:39 PMThey essentially go through multiple rounds of rounding:
50.4438
50.444
50.44
50.4
50

t

Tomas Muchka

06/29/2023, 2:39 PMI see, sorry, I misunderstood. In such a case there is FLOOR, which rounds down 🙂 . https://help.gooddata.com/doc/growth/en/dashboards-and-insights/maql-analytical-query[…]e/numeric-functions/rounding-and-truncation-functions/floor/

m

Mitchel Roling

06/29/2023, 2:39 PMYes, but a number like .50495 should be rounded UP

Mitchel Roling

06/29/2023, 2:40 PM.50495
.5050
.505
.51

Mitchel Roling

06/29/2023, 2:40 PMIf I wrap enough round functions around the number, it also goes through these steps.

👍 1