Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
bvy
Helper V
Helper V

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 5
andhiii079845
Super User
Super User

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 🙂





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Image attached. Thank you again. 

bvy_0-1678049942188.png

 

Why do you not send it before. 🙂 I will try it tomorrow morning. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Super User
Super User

Hi, 
was works in my example:

Bildschirmfoto 2023-03-05 um 21.15.37.png

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],";"))
 
Bildschirmfoto 2023-03-05 um 21.15.57.png

Bildschirmfoto 2023-03-05 um 21.16.07.png





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




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. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.