Forum Discussion
Ant_BM
3 years agoNew Member
Distinct count based on all selected values
Hi all, I have a Count problem that I can't seem to find an answer to. I have two tables Events and Event_Categories: Event ID 111 112 113 114 Event_categories...
vk_pbi
Resolver II
3 years agoHi
Please try this below DAX
cnt =
VAR _Combine =
CONCATENATEX(
Event_categories,
Event_categories[Event ID],","
)
VAR _CountRows=
COUNTX(
VALUES(Events[ID]),
_Combine
)
RETURN
_CountRows- Ant_BM3 years agoNew Member
Hi vk_pbi,
Thank you for the reply.
I tried the DAX and it returns a distinct count where the category is A OR B whereas I'm hoping to return a count where Event_ID is present for all of the selected slicer values (i.e. A and B):In the above example the desired result would be 1
- vk_pbi3 years ago
Resolver II
I think, i made it a bit complicated, but lets check it out
cnt = VAR _NoofselectedValues = COUNTROWS(ALLSELECTED(Event_categories[Category])) VAR _Combine = CONCATENATEX( Event_categories, Event_categories[Event_ID],"," ) VAR _Combine_cat = CONCATENATEX( Event_categories, Event_categories[Category],"," ) VAR _CountRows= IF( NOT CONTAINSSTRING( MAX(Event_categories[Category]), _Combine_cat ), COUNTX( VALUES(Events[ID]), _Combine ), BLANK() ) VAR _Result1 = IF( _NoofselectedValues >1, _CountRows, COUNTX( VALUES(Events[ID]),_Combine) ) RETURN _Result1