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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

how to create a measure which checks if selected value contains in another table & filters third tab

Hello,

 

Please help me in creating a measure to achieve the below ask.(sample pbix attached)

sample pbix 

I have 3 tables namely

Main

stramzik_5-1599111868216.png

Detailed

stramzik_6-1599111889861.png

 

City

stramzik_7-1599111907831.png

 

 

Main and Detailed are related based on column "id" however City is not related to any other table.

 

what I'm trying to achieve is if I select a city or multiple cities from the slicer created from the City[Cities] example lets say I select "san fransisco" ,"washington" and "france" I want the Main table to be filtered of id's if the city contains in start or end city. If you look the below examples since id = d001 does not contain any of the selected city its excluded similarly if id a001/c001/b001 contains at least one city from the selected list so it should show the entrie entries instead of just the entries which are selected. Please advise on how to achieve this?

 

 Below is a sample example i've shown

sample matrix visual BEFORE SELECTION

stramzik_9-1599112102046.png

sample matrix visual AFTER SELECTION

stramzik_10-1599112124719.png

 I hope i've explained this properly please let me know if you have any questions.

Kindly help thank you

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

This was a bit harder than expected 🙂

Take a look at the attached file and the "Filter" measure. 


Connect on LinkedIn

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Anonymous , Trt like

calculate(count(Detailed[Id]), filter(Detailed, Detailed[Start City] in values(City[Cities])))
or
calculate(count(Detailed[Id]), filter(Detailed, Detailed[End City] in values(City[Cities])))

or
calculate(count(Detailed[Id]), filter(Detailed, Detailed[Start City] in values(City[Cities]) || Detailed[End City] in values(City[Cities])))

or
calculate(count(Detailed[Id]), filter(Detailed, Detailed[Start City] in allselected(City[Cities]) || Detailed[End City] in allselected(City[Cities])))

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
Anonymous
Not applicable

@amitchandak 

Those measure which you mentioned filters out Detailed table whereas I want the main table to be filtered based on the filter applied on detailed table so the complete details of an ID show up even if a single city is in the list.

 

example o/p when i use the meaure as : calculate(count(Detailed[Id]), filter(Detailed, Detailed[Start City] in allselected(City[Cities]) || Detailed[End City] in allselected(City[Cities])))

stramzik_0-1599113474226.png

expected ouput for same selection

 

stramzik_0-1599114172367.png

 

tex628
Community Champion
Community Champion

This was a bit harder than expected 🙂

Take a look at the attached file and the "Filter" measure. 


Connect on LinkedIn
Anonymous
Not applicable

@tex628 
WOW you are genius 👏

 

Your solution works great. I've breaking my head for weeks to figure this out honestly i had no idea you can save a table inside a variable and access its columns.... Thank you very much I learnt quite a few tricks with your solution.

 

One last favour could you please point me to a good source where I can learn the basics to advance level or DAX? Course on SQLBI is pretty expensive are there any free course where I can learn from basics to advance? I've been strguggling to understand how the computation happens(row wize or colum wize etc) 

tex628
Community Champion
Community Champion

Honestly speaking I don't know of any structured training that is either free or not terribly expensive. Most free material that can be found is generally aimed at either specific issues/syntax or showcase how to do "cool" workarounds like creating bookmark filter panes and similar. Most courses are generally very basic. 

I'm really hoping that something comes along that is similar to W3Schools and allows you to experience and actively practice advanced DAX / Power Query. 

Br,
J


Connect on LinkedIn
Anonymous
Not applicable

@tex628 completely agree something like w3schools would be so cool.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors