Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Can't create a static measure.

I have a Dashboard where I display population. I can select small population areas from a slicer, map visual or stacked bar chart and other visuals update to reflect these selections.

 

I am trying to get a card to update with the selected small percentage areas as a percentage of grand total when they are selected on either the map visual or stacked bar chart. I can get a measure to work with a slicer, but I can't get this to work when I select small areas using other visuals. I either get an error or 100%

  

I was going down two paths and neither seem to work no matter what I try or what I find for similar issues online. 

 

1. Create a static measure with the sum of population that doesn't change when items in visuals are selected. 

2. Allow me to create a measure that I can divide the total by only items selected. 

 

Any ideas or suggestions to point me in the right direction would be most helpful. 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    Percent =
    CALCULATE ( SUM ( 'Table'[Population] ) )
        / CALCULATE ( SUM ( 'Table'[Population] ), ALLSELECTED ( 'Table' ) )
    

    I add a slicer and I can use it in any visual.

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

3 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Got this working from the stacked bar chart but can't get it working from map visual. Doesn't seem to filter through the stacked bar chart visual.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    Percent =
    CALCULATE ( SUM ( 'Table'[Population] ) )
        / CALCULATE ( SUM ( 'Table'[Population] ), ALLSELECTED ( 'Table' ) )
    

    I add a slicer and I can use it in any visual.

     

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Yilong. Good to get this solution but could get this working with a slicer but not by using a visual. I did get a solution using two different measures, one to select all small areas and the second to only bring back data from areas selected on visual. 

      Population All Areas Selected = CALCULATE([# Population total], ALL('2022_Data'[Small Areas]))
      % Population All Areas Selected = DIVIDE([# Population total],[# Population All Areas Selected])