Percentage of total - Query builder

Hello,

I'm trying to create a percentage of total that would calculate dynamically based on user (dashboard) filters.
So when a user chooses a value in a filter, I want to be able to show the percentage of rows with that value from the total rows.

I know it's currently possible through SQL questions. But my need is to do this via Query builder.

Is there a way to do it currently out of the box? And if not, what are the workarounds for this? Even if it means using multiple piled questions.

I'd really appreciate any help.

Hi @ramiouanes
So what is the reason behind having to do it in GUI vs SQL?
It is going to be some very messy GUI you're going to end up with, which just means it's going to be a lot harder to understand and change versus creating it in SQL.

Thank you @flamber for your quick reply.
This is needed because we want to make use of the models and give business users ability to create their own questions/dashboards.

SQL is just not an option for Business Users... So I want to know what are other available options to help decide what to do. I would appreciate it if you would give me the steps to do this.

Also, is out of the box support for this feature in the roadmap? A great way to do it is to be able to use filters in custom expressions. That way it'll be as simple as doing something like: {Filter Value} / [sum for all rows]. This will also open a lot of other possibilities by using dashboard filters without having to map them necessarily to a question field. If filters can be created as a standalone object independently from questions, that will really be great!

@ramiouanes Metabase is limited by certain database constraints, so some things would require Metabase handling things in a middlelayer, which is complicated and slow compared to letting the databases do what they are best at.

I would recommend that you tell the users to use something like this:
CountIf([column] = "my_filter value") / Count

There's a request for it:
https://github.com/metabase/metabase/issues/2120 - upvote by clicking :+1: on the first post

Is my "my_filter value" in your example static?

If yes, unfortunately that doesn't fix the issue at all.
Telling the users to set a static value is not an option, the value needs to be dynamic and to calculate on the fly based on the filter selection.
These are the basics in all reporting tools. Even in Excel.

I hope this gets fixed quickly as it's a basic feature and unfortunately a blocking point for our delivery.

3 Likes

Any update on this? I am trying to achieve the same thing as @ramiouanes - showing a filtered count (via dashboard filters) as a percentage of an unfiltered count.