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

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

Reply
powerx786
Microsoft Employee
Microsoft Employee

How to filter related table based on an inactive relationship

Hi, I have two tables with an active and inactive relationship between them. 

powerx786_0-1598208166898.png

The active relationship is from Table4[Id] <->Table5[Number]

The inactive relationship is from Table4[Name] <->Table5[Name] 

 

These are the values

 

powerx786_0-1598238628092.png

 

 

I want to generate the CalculatedTable based on the row selected based on Name column in Table4. 

StaticFilteredTable has this code which is not what I want as this does not get modified by Table4 selction:

StaticFiltered = FILTER(Table5,CONTAINS(Table4,Table4[Name],Table5[Name]))

 

This is the code for CalculatedTable but it is always giving me a blank result as shown below:

 

CalculatedTable =
VAR SELECTED = SELECTEDVALUE(Table4[Name], "not selected")
RETURN FILTER(Table5,Table5[Name]=SELECTED)

 

model3.PNG

Any ideas on how to generate the filtered table based on dynamic slection from Table4?

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @powerx786 ,

According to my understanding, you want to filter StaticFiltered table based on selected Name in Table4, right?

 

You could use the following formula:

Measure =
VAR _SELECT =
    SELECTEDVALUE ( Table4[Name] )
RETURN
    IF ( SELECTEDVALUE ( StaticFiltered[Name] ) = _SELECT, 1, 0 )

Then apply the measure(set as is 1) to the visual filter. My visualization looks like this:

8.24.5.1.png

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

View solution in original post

11 REPLIES 11
Anonymous
Not applicable

Hi @powerx786 ,

According to my understanding, you want to filter StaticFiltered table based on selected Name in Table4, right?

 

You could use the following formula:

Measure =
VAR _SELECT =
    SELECTEDVALUE ( Table4[Name] )
RETURN
    IF ( SELECTEDVALUE ( StaticFiltered[Name] ) = _SELECT, 1, 0 )

Then apply the measure(set as is 1) to the visual filter. My visualization looks like this:

8.24.5.1.png

Is the result what you want? If you have any questions, please upload some data samples and expected output.

Please do mask sensitive data before uploading.

 

Best Regards,

Eyelyn Qin

Hi @Anonymous , yes! this result you showed is what I want. 

 

Can you expand on "Then apply the measure(set as is 1) to the visual filter.".

How would I apply the measure (with values 0 or 1) to the visual ?

 

Thanks!

Anonymous
Not applicable

@powerx786 ,like this:

8.24.5.2.PNG

Click “Apply filter” ,after click a Name in Table4, the visual will be right.

 

Best regards,

Eyelyn Qin 

Thanks @Anonymous ! 

 

I modified the measure definition a little bit to meet my need, which seems to work well and filters StaticFiltered table when a row from Table4 is selected (both dont need to be selected).

 
Measure =
VAR _SELECT =
    SELECTEDVALUE ( Table4[Name] , "NaN")
RETURN
    IF ( CONTAINS(StaticFiltered, StaticFiltered[Name], _SELECT) || _SELECT="NaN", 1, 0 )
 

Then I had to add the measure as one of the 'Values' in the table visual and then I was able to filter the visual by the measure. The only drawback seems to be that the measure gets added as a column in the table visual. I wonder if there is a way to hide it from appearing in the visual. Other than that, it seems to work great.

 

Thanks!

 

Anonymous
Not applicable

Hi @powerx786 ,

For my test, just put the measure into the filter pane, it does not need to be put into the table as a Value.

Could you upload a sample pbix file?

Best regards,

Eyelyn Qin

Hi @Anonymous yes it works like you mentioned. The meaure needs to be dragged into the filter pane.

Thanks!

Fowmy
Super User
Super User

@powerx786 

Creating a dynamic table based on a selection from a slicer value?
Calculated tables get materialized at the time of creating, refreshing, and loading them. Any selection from canvas cannot impact them. Am I missing something here?

________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube, LinkedIn

  

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

powerx786
Microsoft Employee
Microsoft Employee

Ok @Fowmy  then is there any way to solve this issue?

Greg_Deckler
Community Champion
Community Champion

@powerx786 - Use USERELATIONSHIP.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  I have found USERELATIONSHIP works with measures but not for filtering a table. Maybe I am doing something wrong .. (?)

This is the calculation I tried but it does not filter however when I select a row in Table4

 

TableByUseRelationship = CALCULATETABLE(Table5, USERELATIONSHIP(Table5[Name], Table4[Name]) )

 

@powerx786 - I'm not sure that USERELATIONSHIP is a valid filter context for CALCULATETABLE.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.