Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
lazarus1907
Helper I
Helper I

Filter within filter?

Hi,
I'm struggling to do this and I suspect the solution will involve nested filters, but I'm not getting any success so far.  Let me illustrate the problem with an example, because it's tricky to explain:
This is the MAIN TABLE:

CodeClassValue
1A0
1A0
1A2
1B6
1B3
1B2
2A0
2A0
2B11
2B13
3A0
3A0
3B77
4A0
4A0
4B17
4B19
5A0
5A0
5A3
5A0
5A0
5B21
5B23
5B27

If we add the Values filtering by class = 'A' for each Code, we get the virtual table SUB_TABLE_1:

CodeValue
111
224
377
436
5

71

If we add the Values filtering by class = 'B' for each Code, we get the virtual table SUB_TABLE_2:

CodeValue
12
20
30
40
53

What I want to do is add only the rows of the SUB_TABLE_1 for the Codes where the sum of the values of SUB_TABLE_2 is not zero, ie. only Code = 1 (Value = 2) and Code  = 5 (Value = 3). In other words, something like this:

CodeValue
111
571
TOTAL:82

The original table is obviously much bigger, but what I am trying to get is this kind of total (82 in this example) by adding all the values for class A in the MAIN TABLE, only if the sum of the values for each particular Code for class B is not zero. I am not interested in creating any intermediate tables (eg. SUB_TABLE_1 & SUB_TABLE_2) if this can be avoided through DAX -I just need the total (82 in this example).
I hope this makes sense.
I would be very grateful If anyone has any suggestion or solution.

Thanks

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

There are multiple ways to achieve this.

 

In Power Query you can create reference queries and then group them as needed.

In DAX you can create calculated columns that indicate inclusion/exclusion flags,  or you can create temporary tables, join them as needed ad then aggregate the results.

 

Which approach do you prefer, Power Query or DAX?

 

BTW, your first two sample outcomes for A and B are the other way round.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

There are multiple ways to achieve this.

 

In Power Query you can create reference queries and then group them as needed.

In DAX you can create calculated columns that indicate inclusion/exclusion flags,  or you can create temporary tables, join them as needed ad then aggregate the results.

 

Which approach do you prefer, Power Query or DAX?

 

BTW, your first two sample outcomes for A and B are the other way round.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.