Forum Discussion
DAX help on category
- Anonymous1 year ago
Hi Lauraeire_81 ,
Use the following DAX to create a new table:
Table 2 = VALUES('Table'[Countries])Create a relationship between the two tables:
Create a measure:
Measure = VAR _currentCT = SELECTEDVALUE ( 'Table 2'[Countries] ) VAR _values = VALUES ( 'Table'[Countries] ) RETURN IF ( SELECTEDVALUE ( 'Table 2'[Countries] ) IN _values && ISFILTERED ( 'Table'[Countries] ), "'" & CONCATENATEX ( FILTER ( 'Table', 'Table'[Countries] = _currentCT ), 'Table'[Food], " and " ) & "' found in '" & _currentCT & ". " & "Count of " & COUNTROWS ( FILTER ( 'Table', 'Table'[Countries] = _currentCT ) ), IF ( NOT ISFILTERED ( 'Table'[Countries] ), "'Please select an option'" ) )Drag the fields of Table2 to the table visual object, the page effect is as follows:
I have tested it and found that select all and select no object is one case, to show all cases when select all. I have a workaround: I can drag the “Table” table's countries field and count measure to the table's visual object, save the slicer select all case as a bookmark, and insert a button. Insert a button and set the action of the button to this bookmark.
The pbix file is attached.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
Lauraeire_81 sorry for the late reply, but yes it could be possible. As I do not know how to detect the all select value, I could suggest to test if the NbCat (in my formula) is equal to the number of possible values :
IF( NbCat = CALCULATE( DISTINCT( Products[Category] ) , ALL(Product) ) ,"All Selected" )
It should do the trick.
Let us know