Hello, could I get advice on how to calculate Rate...
# gooddata-platform
a
Hello, could I get advice on how to calculate Rate = count / total_count of the column?
j
Hello Ales, if you are looking for an average here, you might need to use the in-built function:
a
Hey 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
Could 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
just DM you. Thanks!
j
If 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
Hey 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
Oh 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?
Looks 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
yep, this is it! 🥳 Thanks a lot, Jan!
👋 2