Forum Discussion
Return SELECTED COUNT by GROUP ?
Hello. I have a type/subtype structure in a single Table. It might be something like State and City. So...
Ohio
> Cleveland
> Columbus
Kentucky
> Louisville
Pennsylvania
> Pittsburgh
> Harrisburg
Users make slicer selections on the City. I need a DAX measure that tells me if two or more cities are SELECTED for any ONE state, and additionally returns the names of the selected cities.
So if the user selects Cleveland and Louisville, return nothing. If they select Cleveland AND Columbus, return the names of both.
I started writing something with the SUMMARIZE function to group the number of distinct cities for each state, but i can't work in the selected count part.
Can someone help? Thanks.
5 Replies
- andhiii079845
Solution Sage
Hi,was works in my example:β
Measure =VAR _selectcity = SELECTEDVALUE('Table'[City])VAR _selectstate = SELECTEDVALUE('Table'[State])VAR _selectestatedistinct = DISTINCTCOUNT('Table'[State])RETURN IF(_selectestatedistinct>1,"Nothing",CONCATENATEX('Table','Table'[City],";"))β
β
- bvy
Helper V
Thank you. That doesn't really work at all though. If one city is selected, it returns that city. If multiple cities are selected for several states, it returns nothing.
To add some clarity, if multiple cities are selected for ANY state, it should return the city/state groups that are selected.
- andhiii079845
Solution Sage
Make a clear example with input and your desired output. Because you write first:
So if the user selects Cleveland and Louisville, return nothing. If they select Cleveland AND Columbus, return the names of both. This do the measure π
Thank you π- bvy
Helper V
Image attached. Thank you again.
- andhiii079845
Solution Sage
Why do you not send it before. π I will try it tomorrow morning.