Using 2 metrics with different filters in a same question does not work

Hello dear community!

When using 2 different metrics built with 2 different filters in a same question I noticed Metabase adds the filters for each metric whereas I was expecting each one is calculated on its own filter.

Is it the expected final behaviour? I think it would be more relevant if each metric would conserve it's own filter.

For example if we define two metrics like:

Metric A = Sum(Turnover) Where Dim1 = "a"
Metric B = Sum(Turnover) Where Dim2 = "b"

Then asking for Metric A and B in the same question willl result the request to be :

Sum(Turnover), Sum(Turnover) 
Where Dim1 = "a" AND Dim2 = "b"

Rather than

Sum(Turnover Where Dim1 = "a"),  Sum(Turnover Where Dim2 = "b")

Wich would be achievable in SQL with a simple case when statement.

The workaround is to use CountIf or SumIf function in the view and using a same Segmetn for each metric but I guess this design is more restrictive .

What do you think?

Metabase Version: 0.43.2
Database : Redshift
Os: macOs Catalina
Browser: Google Chrome Version 106.0.5249.91

Hi @felici1b
In your example, you could use SumIf Custom Expression instead of Metrics:
https://www.metabase.com/docs/latest/questions/query-builder/expressions-list#sumif

Using multiple Metrics with conflicting filters will cause this issue:
https://github.com/metabase/metabase/issues/25455 - upvote by clicking :+1: on the first post

1 Like