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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
MightyMicrobe
Helper II
Helper II

Cross-filter on a related table

I have two tables: one with all customer IDs and their attributes and the other with a subset of these IDs and some other attributes: 

Table 1 Table 2
ID(expected result)IDFooSpam
101Both10111
102None10401
103None10701
104Spam10910
105None11011
106None10801
107Spam   
108Spam   
109Foo   
110Both   
111None   
112None   

The tables are linked by IDs, which works well: I can create filtered calculations like DISTINCTCOUNT('Table1'[ID], FILTER('Table1', OR([Foo]=1, [Spam]=1)... so far so good. 

 

What I'm trying to create, however, is a SWITCH or IF measure in Table 1 which would put a flag against each ID in Table 1 based on the values of [Foo] and [Spam] in Table 2 AND put 'None' if the ID is not found in Table 2 altogether. 

 

Something like

IF 'Table2'[Foo]=1 THEN 'Foo',

ELSEIF 'Table2'[Spam]=1 THEN 'Spam',

ELSEIF AND('Table2'[Foo]=1, 'Table2'[Spam]=1) THEN 'Both'

ELSE 'None'

 

But all I can see from Table 2 when trying to build the SWITCH is the aggregate metrics, not the [Foo] and [Spam] columns.

 

What gives?

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@MightyMicrobe 

 

Please try this

RESULT = 
VAR FOO=MAXX(FILTER(Table2,Table1[ID]=Table2[ID]),Table2[FOO])
VAR SPAM=MAXX(FILTER(Table2,Table1[ID]=Table2[ID]),Table2[SPAM])
RETURN IF(FOO=1 && SPAM=1 , "BOTH",IF(FOO=1 &&SPAM=0,"FOO",if(FOO=0&&SPAM=1,"SPAM","NONE")))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
ryan_mayu
Super User
Super User

@MightyMicrobe 

 

Please try this

RESULT = 
VAR FOO=MAXX(FILTER(Table2,Table1[ID]=Table2[ID]),Table2[FOO])
VAR SPAM=MAXX(FILTER(Table2,Table1[ID]=Table2[ID]),Table2[SPAM])
RETURN IF(FOO=1 && SPAM=1 , "BOTH",IF(FOO=1 &&SPAM=0,"FOO",if(FOO=0&&SPAM=1,"SPAM","NONE")))

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amitchandak
Super User
Super User

@MightyMicrobe , Not sure I got it , Try

New column in Table 1 = maxx(filter(table2, table2[ID] = Table1[ID]), Switch(True(), 'Table2'[Foo]=1 , "Foo",'Table2'[Spam]=1 , "Spam",
AND('Table2'[Foo]=1, 'Table2'[Spam]=1) , "Both",
"None"
))

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hey @amitchandak thank you for your help. My main problem was that the relationship was single-directional, that's why I could not see the fields. 

I modified your formula so that 'Both' shows up first, otherwise, it did not show up because every ID only evaluated once. 

However, I do not get the 'None' in the results, only blanks -- any ideas?

Column =
MAXX(
FILTER('Table2', 'Table2'[ID]='Table1'[ID]),
SWITCH(TRUE(),
AND('Table2'[Spam]=1, 'Table2'[Foo]=1),"Both",
'Table2'[Spam]=1,"Spam",
'Table2'[Foo]=1,"Foo",
"None"
))

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.

Top Solution Authors