redash icon indicating copy to clipboard operation
redash copied to clipboard

Displayed as a value multiplied by 100 before displaying the percentage

Open masayuki038 opened this issue 2 years ago • 12 comments

Issue Summary

@willvictor reported in https://github.com/getredash/redash/issues/6579:


I did notice what seems to be a breaking change in the latest version: Screen Shot 2023-11-08 at 9 00 11 AM

  • for table visualizations that have a percentage display, it seems the formatter now multiplies the value by 100 before displaying the percentage. Previously the formatter did not do this.
  • This means if I wanted to display 60% previously, I would write sql that would output 60%, for example SELECT 100 * 6/10 as perc, then the format of 0,0.0% would display 60.0%, but now it displays 6000.0%.

Do you know what might have caused this? Was it intentional?


Steps to Reproduce

(T.B.D.)

Technical details:

  • Redash Version: redash/redash:preview
  • Browser/OS:
  • How did you install Redash:

masayuki038 avatar Nov 09 '23 13:11 masayuki038

That percentage multiplier thing sounds familiar, as in... I think @eradman was doing some work to fix something else about a month ago, and this might be an unintended side effect.

@eradman If this doesn't immediately jump out at you, I can go digging through stuff and try and turn up the thing I was thinking of. :smile:

justinclift avatar Nov 09 '23 19:11 justinclift

It sounds like the result of https://github.com/getredash/redash/pull/6344. I will try to confirm

Both and and new libraries appear to produce the same results:

> var numbro = require("numbro");
> num = numbro(0.25);
t { _value: 0.25 }
> num.format('0.0%');
'25.0%'
> var numeral = require("numeral");
> num = numeral(0.25);
{ _input: 0.25, _value: 0.25 }
> num.format('0.0%');
'25.0%'

eradman avatar Nov 09 '23 20:11 eradman

Ahhhh. Yep, I think that's the one I was half-remembering. :smile:

Thanks for confirming I wasn't imagining things @eradman. :grin:

justinclift avatar Nov 09 '23 20:11 justinclift

I can confirm that this behavior changed

Format:

value: 0.00 percent: 0.0%

Redash 23.11.0-dev redash23-11-percent

Redash 10 redash10-percent

But I would say the new result is correct, since this is how numeral and numbro format a number when % is added!

eradman avatar Nov 09 '23 20:11 eradman

@eradman @justinclift Thanks! Understood.

I agree with you. I also think it would be natural to display the percentage as 0.25 => 25%. I think the update makes sense.

The next issue is compatibility. This will be a breaking change. This change will require Redash users to rewrite their queries. So let me suggest one thing. Can we do it like below?

  • Introducing a new environment variable that allows you to toggle whether to multiply by 100 or not
  • The next release will continue to display numbers that are not multiplied by 100 by default
    • Of course, it can toggle with a new environment variable
  • From the next major version up, the default will be to display the value multiplied by 100

What do you think about this?

masayuki038 avatar Nov 10 '23 03:11 masayuki038

That's a good point about the backward compatibility aspect. If we keep the same default as the previous versions, that'll likely be one less thing people (who are upgrading) have to worry about.

justinclift avatar Nov 10 '23 06:11 justinclift

@masayuki038 the strategy you outlined make sense. I will look into adding an environment variable for maintaining compatibility.

eradman avatar Nov 10 '23 15:11 eradman

@justinclift @eradman Thanks for your confirmation.

@eradman

I will look into adding an environment variable for maintaining compatibility.

Thanks!

masayuki038 avatar Nov 10 '23 16:11 masayuki038

This plan makes sense to me! Thank you all!

willvictor avatar Nov 10 '23 18:11 willvictor

Hi Everyone,

Is there any movement on this issue? Right now our existing alerts/queries/dashboards are still off by 2 orders of magnitude.

If no movement, is there anything I can do in the meantime?

Thanks! Will

willvictor avatar Nov 20 '23 22:11 willvictor

We have a PR open here, but we're waiting to see if numbro updates on their end. If you need a fix right now, I'd suggest it's probably best to update your queries to divide by 100, or change the formatting on the outputs - but this is obviously pretty time intensive. You could also build the image in #6595 yourself and deploy that instead, maybe?

guidopetri avatar Nov 20 '23 23:11 guidopetri

@willvictor https://github.com/getredash/redash/pull/6595 was merged. I have confirmed "0.25" is displayed as "0.25%" with "0.00%" format in redash/redash:preview now.

image

Please try it if you have time. Thank you for the report. If there are no particular problems, this issue will be closed after one week.

masayuki038 avatar Nov 30 '23 12:11 masayuki038