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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
pbhat89
Helper II
Helper II

Cross filtering across tables

My one table is given in the format below 

ID Age Height Score

1   20     167     120

2   30     150     122

3   40     190      100

 

Table 2 is 

ID Condition

1    A

1    A

2    B

3    C

 

Now i have joined the two tables as one to many join (tab 1 to Tab 2) . In dashboard i want the filter (in addition to other filters) to be :

 

Drop downlist of - all selected originally

A

B

C

 

Measure_C = count(ID) = 3

Now filter out (unselect) condition A from table 2 , Measure_C now = 2 ( as ID 1 gets dropped )

 

How do i achieve this ? i have selected one-to-many join and apply filters both directions - but doesn't work. i want it to only apply on table 1. Note i need unselecting - not selecting i.e. if i click on A from drop down - measure = 1 ( as ID 1 is only counted ) . This is where i am currently. Appreciate your help.

1 ACCEPTED SOLUTION

Hi @pbhat89 ,

 

Do you want the result is the measure or the table?

If the measure is your result, please refer the following steps.

 

1. Change the Both direction to Single.

 

cross4.jpg

 

2. Then create a measure like this,

 

Measure = 
var _selected = SELECTEDVALUE('Table 2'[Condition])
var _select_count = CALCULATE(COUNT('Table 1'[ID]),FILTER('Table 2','Table 2'[Condition]=_selected))
var _Total = COUNT('Table 1'[ID])
return
_Total - _select_count

 

cross5.jpg

 

cross6.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

View solution in original post

8 REPLIES 8
v-zhenbw-msft
Community Support
Community Support

Hi @pbhat89 ,

 

If you have to use the Table 1[ID], maybe you can try to change the relationship direction to Both.

 

cross1.jpg

 

cross2.jpg

 

cross3.jpg

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

I understand the example given by me may not be really representative. So updating the example and sharing expected output of the table and a measure. 

 

TABLE 1

pbhat89_1-1601273098805.png

Each row shows 1 ID only. ID does not repeat in TABLE 1

Measure : Count_of_unique_ID = 8

 

TABLE 2 

pbhat89_2-1601273232972.png

Each row is a unique combination of ID and Condition. i.e. ID,condition won't repeat. The table may have <= IDs from table 1. E.g. it will not have a new ID 10 which has not occured in table 1.  

 

The current join is in BOTH direction and via ID 

 

FILTERS & MEASURE - EXPECTED OUTPUT.

FILTER 1 = AGE < 35 

FILTER 2 = EXCLUDE (not filter on) IDs with CONDITION (A)

 

TABLE 1 after filters 

pbhat89_3-1601273423442.png

Measure : Count_of_unique_ID = 4

 

Right now the filter 2 above - filters on i.e. selects the IDs where A happened where as i want to remove the IDs where A happened. and then update the measure Count_of_unique_ID

 

Hope the query is clear now?

 

 

 

 

 

 

 

Hi @pbhat89 ,

 

Do you want the result is the measure or the table?

If the measure is your result, please refer the following steps.

 

1. Change the Both direction to Single.

 

cross4.jpg

 

2. Then create a measure like this,

 

Measure = 
var _selected = SELECTEDVALUE('Table 2'[Condition])
var _select_count = CALCULATE(COUNT('Table 1'[ID]),FILTER('Table 2','Table 2'[Condition]=_selected))
var _Total = COUNT('Table 1'[ID])
return
_Total - _select_count

 

cross5.jpg

 

cross6.jpg

 

If you have any question, please kindly ask here and we will try to resolve it.

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BTW, pbix as attached.

In the above -

 

solution works but only for one condition. If i select two conditions i.e. A and B . then it doesn't work and reverts to the old count.

AllisonKennedy
Community Champion
Community Champion

Do you need Table1 for anything?

Can you try Measure_C = DISTINCTCOUNT(Table2[ID])

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Table 1 is actually the main table for me to do the counts.

For e.g. my filters are :

 

Age < 35 

measure_C = 2 ( ID 1 , 2)

 

filter out (unselect) condition A 

measure_C= 1 ( ID 2 ) 

 

Basically i want to filter to work oppsite i.e. when i select the conditions from a list , it should remove the corresponding IDs from the main table. As a default it should have everything to start. 

It would be easier just to change the selection controls on the slicer, and turn off single select with ctrl and adjust a few other things to get it how you want.

If you absolutely need to restrict them to a single item to exclude, then you will need to create a slicer table that is NOT related to the data so that when you select an item other items are still visible;
Create a NEW TABLE:
Slicer = VALUES(table[item])

Then you'll need to create a measure, possibly using:

Items to show = IF(SELECTEDVALUE(table[Item]) NOT IN Values(slicer[item]), "Yes", "No")

Finally, use that measure to filter the visuals.

Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Understand your approach and makes sense. I was able to create a slicer first with below :

 

Disclosures = DISTINCT(VALUES(Table2[Condition]))

 

Now for the measure : i believe the selected value should be on the slicer - since i will select the ones i want to be filtered out in table 2 i.e. condition ?  And "NOT IN" is not working in DAX.  What is the correct approach for creating this measure ? Below my attempt which gives error on NOT IN

 

Filter_condition = IF(SELECTEDVALUE(Disclosure[Condition]) NOT IN Values(Table2[Condition]), "Yes", "No")

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.