Hello,
could I get advice on how to calculate Rate...

# gooddata-platforma

Ales M.

12/08/2022, 9:05 AMHello,
could I get advice on how to calculate Rate = count / total_count of the column?

j

Julius Kos

12/08/2022, 9:47 AMHello Ales, if you are looking for an average here, you might need to use the in-built function:

a

Ales M.

12/08/2022, 9:58 AMHey Julius, thanks for the help.
But I would like to have a rate for each row. The calculation of the first row should be 57 / 365 (total sum of the whole column) = 15,6%

j

Julius Kos

12/08/2022, 12:01 PMCould you please DM me and send me the workspace ID where you are creating the particular insight? We will need to check it in order to advise further. Thanks!

a

Ales M.

12/08/2022, 12:24 PMjust DM you. Thanks!

j

Jan Soubusta

12/08/2022, 12:45 PMIf I am not mistaken, in the case of such ratios, it can always be solved by creating a MAQL metric, example:

Copy code

`SELECT SUM(x) / ( SELECT SUM(x) BY ALL OTHER )`

Right?a

Ales M.

12/08/2022, 12:59 PMHey Jan, this looks promising. Is it possible to spilt by columns? In my case by column called Attemps. Becaouse now it calculate count divide total count from whole table. But I need count divide total count of column.

j

Jan Soubusta

12/08/2022, 1:03 PMOh I see, you wanna calculate ratio in a pivoted column!
Well, I do not know how to do that, pivoted column is created dynamically, so it does not exist as an attribute/fact in the model, from which MAQL metric could it take.
WDYT, **@Jakub Sterba**?

Jan Soubusta

12/08/2022, 1:14 PMLooks like I am wrong.
IMO, It should work, you just need to add the pivoted column into the metric:

Copy code

`SELECT COUNT(x) / ( SELECT COUNT(x) BY Attempts ALL OTHER )`

👍 2

a

Ales M.

12/08/2022, 1:20 PMyep, this is it! 🥳 Thanks a lot, Jan!

👋 2