Forum Discussion
How to filter rows in a table based on rows in another table that has been filtered
I'm trying to figure out how to create a measure that calculates a value in a table based on filtered rows in another table.
Table 1 would be filtered by a slicer to select condition.
Using the Member ID's from Table 1, I want to filter Table 2 to get only those Member ID's that are in the Table 1 filtered row.
Then sum the "Amount Paid.
In my two tables Member ID is not unique so no relationship can be establishied.
Any help appreciated!
9 Replies
- ChrisMendoza
Resident Rockstar
hello jasonbakersd,
When you say In my two tables Member ID is not unique..., do mean that 'Table 1'[Member ID] does not equal 'Table 2'[Member ID] or in other words 'Table 1' value of Dozer is not the same as 'Table 2' value of Dozer?
Or do you mean that you have mulitple Dozer's in either table and a relationship can't be built because their are duplicate values of Dozer?
My guess is you need to build a 'lookup table' of unique [Member ID] then build the relationship between the 'Table 1'[Member ID] (Many:1) -> 'lkupTable'[Member ID] <- (1:Many) 'Table 2'[Member ID]
- jasonbakersd
Helper I
Tables 1 & 2 have many member ID so it would be a many to many relationship.
There is a member table with relationships to both tables.
- ChrisMendoza
Resident Rockstar
How about Merging the two tables? I chose LEFTOUTER, you may require different with your actual data.
- Ashish_Mathur
Super User
Hi,
In Table 1, can there be a case where for Member ID 1, the Condition is Diabetes i.e. can there be a different condition for the same Member ID in Table 1?
Please clarify.
- v-xjiin-msft
Solution Sage
Hi jasonbakersd,
Try this measure:
Sum Amount Paid = CALCULATE ( SUM ( Table2[Amount Paid] ), FILTER ( ALL ( Table2 ), Table2[Member ID] IN SELECTCOLUMNS ( ALLSELECTED ( Table1 ), "Member ID", [Member ID] ) ) )Thanks,
Xi Jin.- jasonbakersd
Helper I
Thanks for the response. I've created the measure using similar logic in my model and it's working pretty well.
I'm thinking I have to play around with the ALL portion as my results are close (compared to database).
I'll want to be able to use this (and similar measures) on time series charts and other visuals.
I'll dig in a bit more and get back to you.
- v-xjiin-msft
Solution Sage
Hi jasonbakersd,
Did you resolve your issue? If so, please kindly mark corresponding reply. It'll benefit others with relevant issue. If not, please feel free to ask.
Thanks,
Xi Jin.