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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MTOnet
Helper III
Helper III

Filter Data Table by a Measure

I am having some trouble finding a solution to my problem that I am trying to solve for a report I am working on.

What I want to do is filter a data table by the result of a measure.  A solution is alluding me, althougn I feel that I am close.  

I have two tables, that have no relation, but do share some common data elements.

Table 1
ID Detected  Assigned
1   PersonA   PersonB
2   PersonD   PersonC
3   PersonB   PersonD
4   PersonE   PersonA
5   PersonB   PersonB
Table2
Person     StatusA StatusB
PersonA       1       2
PersonB       3       4
PersonC       5       6
PersonD       7       8

(In Table2, the status columns are just meant to be representative of the data).

What I am attempting to do, is filter Table2 based on the person selected in Table2. For example, if person B is selected in Table 2, then Table 1 only shows ID 1, 3 & 5 from Table1.

I have a measure which allows me to capture the selected individual in Table2, but I am having difficulty trying to come up with the filter.  I tried to create a calculated column, which gives a result of 1 or 0 if the the Detected or Assigned columns match the selection of Table2 and then set a visualization level filter to only display results that have a 1.  This didnt work, and in reading, it seems to be due to calcualted columns only being generated when the model is created/updated.

I feel this should be able to be done as a measure though, to give the result I want.  However, I am not able to come up with a formula such that it iterates through each item in Table1 to give the result that I can filter on.

Any help or suggestions on how I can solve this is greatly appreciated.

 

 

3 REPLIES 3
Greg_Deckler
Super User
Super User

Perhaps try something like this for your measure:

 

Measure = 
VAR __selected = MAX('Table2'[Person])
VAR __detected = MAX('Table 1'[Detected])
VAR __assigned = MAX('Table 1'[Assigned])
RETURN
IF(__selected = __detected || __selected = __assigned,1,0)

Then add this measure to your Filters and filter for 1



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hi Greg, thanks for the suggestion.  I was able to get the Detected and Assigned with what you provided, but the first part for  selected wasnt working.  I tried to display that on the data table, but when a record is selected, that column is blank.  I tried with my original measure that gets that value and I am seeing the wierdest behavior.  When I select a record from Table2, if I display my measure on a card, it displays the correct value for Person, but if i try to display that value on the data table, it shows as if no record is selected, so my comparison doesn't give the proper results, 

kentyler
Solution Sage
Solution Sage

You might consider using SELECTEDVALUE('table 2'[Person]) against table 2

 

as the argument to a FILTER() function

Matching Rows :=

VAR selected_person =SELECTEDVALUE('table2'[Person])

RETURN

FILTER('table 1',

             'table 1'[Person] = selected_person

          )





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.