Forum Discussion
Help with slicer/table visual and contexts
- 1 year ago
Thanks all for the help. I was able to resolve this. I needed create another relationship between Table3 and Table1 (based on the name many-to-many). I was then able to use that relationship, the name of the person from Table3, the name of the company from Table2, ignore all the rest of the filters (ALL(Table1)) and add a set of filters which match the name and the company from above. This resulted in empty data for all names and the correct data for those who matched. I was able to filter the empty's in the visual and that did the trick.
Thanks again for all your help.
+Ram
Hi RamEHG ,
To achieve the desired output, you need a measure that correctly filters the company based on the selected person and counts the discussions accordingly. Since Table2 and Table3 have a many-to-many relationship, you must ensure that the filter context propagates properly. The approach involves capturing the selected person's company, filtering Table3 based on that company, and then counting the number of discussions for each person in that company from Table1.
The following DAX measure accomplishes this:
Count of Discussions =
VAR SelectedCompany =
SELECTEDVALUE(Table2[CompanyName])
RETURN
CALCULATE(
COUNT(Table1[UniqueID]),
FILTER(
Table3,
Table3[CompNew] = SelectedCompany
)
)
This measure works by first retrieving the company associated with the selected person in Table2 using SELECTEDVALUE(Table2[CompanyName]). Then, it applies a filter on Table3 to only include rows where the company matches the selected company. Finally, COUNT(Table1[UniqueID]) calculates the number of discussions for people within that company.
For example, when John is selected in the slicer, the table visual will display John and Per1 under Company Comp2 with discussion counts of 2 and 1, respectively. Similarly, if Ram is selected, the table will show Ram and Per2 under Company Comp1 with discussion counts of 2 and 0.
To ensure the relationships work correctly, they must be active, and the filtering logic in the measure must be applied correctly. If multiple people are selected in the slicer, SELECTEDVALUE returns BLANK(), so adjustments using VALUES(Table2[CompanyName]) may be needed for multi-selection scenarios. If Table3 does not filter properly, wrapping it with ALL(Table3) inside the FILTER function might help.
Best regards,
Thanks for the quick response. I tried it but it doesnt work. I get the info but I get all rows of Table 1. So essentially for John I get
Ram | 0
John | 2
Joe | 0
Per1 | 2
What I'm struggling with is to be able to get Table1 to filter by not just company but also the selected names in Table3