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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

DAX Help with returning rows

Hi All,

 

I have the below sample data:

 

EE IDNameState
1111SantaNH
1111SantaMA
1111SantaCA
23FrostCA
23FrostNH
123123FairyOH
123123FairyID

 

I have a drop down slicer in my workbook using the "State" field. The records above show what states people lived in. What I want to do is be able to click specifically on the state "NH" in the drop down slicer and have it also return the records where they previously lived because I want to use this in a graph visual, as well as a matrix visual for various records to see where they lived for facilities planning.

 

So for example, if I click on NH, it should just return these records (Santa and Frost):

EE IDNameState
1111SantaNH
1111SantaMA
1111SantaCA
23FrostCA
23Frost

NH

 

If I did not click on NH it would show all records in the table (as if I had just SELECT ALL checked) or the state that I selected otherwise (Ex. CA). 

 

Many thanks!

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

I created an Inverse Selector for this type of thing which might help in your case:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Inverse-Selector/m-p/648290

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Hi @Anonymous ,

Greg_Deckler's solution could work, you could refer to below steps:

Create below new table:

New Table = SELECTCOLUMNS('Table1',"Name",[Name],"State",[State])

1.PNG

Create below measure:

Standard Selector = 
VAR __dept = MAX([Name])
VAR __products = VALUES('Table1'[State])
VAR __table = SELECTCOLUMNS(FILTER(ALL('New Table'),[State] IN __products),"__dept",[Name])
RETURN
IF(__dept IN __table,1,BLANK())

Use 'New Taable'[State] as slicer and set slicer for the measure:

2.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Greg_Deckler
Super User
Super User

I created an Inverse Selector for this type of thing which might help in your case:

 

https://community.powerbi.com/t5/Quick-Measures-Gallery/Inverse-Selector/m-p/648290

 


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thanks, Greg. I'll try this out. 

Hi @Anonymous ,

Greg_Deckler's solution could work, you could refer to below steps:

Create below new table:

New Table = SELECTCOLUMNS('Table1',"Name",[Name],"State",[State])

1.PNG

Create below measure:

Standard Selector = 
VAR __dept = MAX([Name])
VAR __products = VALUES('Table1'[State])
VAR __table = SELECTCOLUMNS(FILTER(ALL('New Table'),[State] IN __products),"__dept",[Name])
RETURN
IF(__dept IN __table,1,BLANK())

Use 'New Taable'[State] as slicer and set slicer for the measure:

2.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-danhe-msft This worked. thank you!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.