Forum Discussion

bvy's avatar
bvy
Icon for Helper V rankHelper V
3 years ago

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

  • 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's avatar
      bvy
      Icon for Helper V rankHelper 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. 

  • 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's avatar
      bvy
      Icon for Helper V rankHelper V

      Image attached. Thank you again. 

       

      • andhiii079845's avatar
        andhiii079845
        Icon for Solution Sage rankSolution Sage

        Why do you not send it before. πŸ™‚ I will try it tomorrow morning.