Forum Discussion

MichaelaMul's avatar
MichaelaMul
Helper III
2 years ago

Calculate function only when selected in filter

Hi

I have a matrix with a measure that shows the total # of accounts for each sales person. The hierarchy is Director, Manager, Geography. This matrix is filterable by Geography, using the Geography table, linked by Geography. I would like to show this measure only when it is filtered to that geography. How do I change the formula? Do I add SELECTEDVALUE?

 

Current Measure:

 

# of Accounts = calculate(COUNTROWS((values('Salesperson Geos'[Geography]))))

 

 

Data Table

 

GeographyTimeProductBrandCategoryEntire CategoryVolume Share
NorthLast 4 WeeksGroup Apple  Apple100
NorthLast 4 WeeksProduct Red AppleOur Brand AppleApple 80
NorthLast 4 WeeksProduct Green AppleGreen AppleApple 20
NorthLast 4 WeeksGroup Grape  Grape100
NorthLast 4 WeeksProduct Purple GrapeOur Brand GrapeGrape 40
NorthLast 4 WeeksProduct Green GrapeGreen GrapeGrape 60
NorthLast 13 WeeksGroup Apple  Apple100
NorthLast 13 WeeksProduct Red AppleOur Brand AppleApple 45
NorthLast 13 WeeksProduct Green AppleGreen AppleApple 55
NorthLast 13 WeeksGroup Grape  Grape100
NorthLast 13 WeeksProduct Purple GrapeOur Brand GrapeGrape 30
NorthLast 13 WeeksProduct Green GrapeGreen GrapeGrape 70
SouthLast 4 WeeksGroup Apple  Apple100
SouthLast 4 WeeksProduct Red AppleOur Brand AppleApple 60
SouthLast 4 WeeksProduct Green AppleGreen AppleApple 40
SouthLast 4 WeeksGroup Grape  Grape100
SouthLast 4 WeeksProduct Purple GrapeOur Brand GrapeGrape 35
SouthLast 4 WeeksProduct Green GrapeGreen GrapeGrape 65
SouthLast 13 WeeksGroup Apple  Apple100
SouthLast 13 WeeksProduct Red AppleOur Brand AppleApple 56
SouthLast 13 WeeksProduct Green AppleGreen AppleApple 44
SouthLast 13 WeeksGroup Grape  Grape100
SouthLast 13 WeeksProduct Purple GrapeOur Brand GrapeGrape 75
SouthLast 13 WeeksProduct Green GrapeGreen GrapeGrape 25
WestLast 4 WeeksGroup Apple  Apple100
WestLast 4 WeeksProduct Red AppleOur Brand AppleApple 70
WestLast 4 WeeksProduct Green AppleGreen AppleApple 30
WestLast 4 WeeksGroup Grape  Grape100
WestLast 4 WeeksProduct Purple GrapeOur Brand GrapeGrape 55
WestLast 4 WeeksProduct Green GrapeGreen GrapeGrape 45
WestLast 13 WeeksGroup Apple  Apple100
WestLast 13 WeeksProduct Red AppleOur Brand AppleApple 30
WestLast 13 WeeksProduct Green AppleGreen AppleApple 70
WestLast 13 WeeksGroup Grape  Grape100
WestLast 13 WeeksProduct Purple GrapeOur Brand GrapeGrape 60
WestLast 13 WeeksProduct Green GrapeGreen GrapeGrape 40
EastLast 4 WeeksGroup Apple  Apple100
EastLast 4 WeeksProduct Red AppleOur Brand AppleApple 65
EastLast 4 WeeksProduct Green AppleGreen AppleApple 35
EastLast 4 WeeksGroup Grape  Grape100
EastLast 4 WeeksProduct Purple GrapeOur Brand GrapeGrape 70
EastLast 4 WeeksProduct Green GrapeGreen GrapeGrape 30
EastLast 13 WeeksGroup Apple  Apple100
EastLast 13 WeeksProduct Red AppleOur Brand AppleApple 40
EastLast 13 WeeksProduct Green AppleGreen AppleApple 60
EastLast 13 WeeksGroup Grape  Grape100
EastLast 13 WeeksProduct Purple GrapeOur Brand GrapeGrape 64
EastLast 13 WeeksProduct Green GrapeGreen GrapeGrape 36

 

Geography Table

GeographyImageURL
Northexample 1
Westexample 2
Southexample 3
Eastexample 4

 

Salesperson Geos Table

ManagerGeography
JoeNorth
JoeWest
HarrySouth
Harry

East

3 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    MichaelaMul Not quite sure I am following. Perhaps create an RLS rule based to filter the data just to what each Manager should see?

    • MichaelaMul's avatar
      MichaelaMul
      Helper III

      Hi Greg,

       

      Sorry after reviewing my issue- I think my main problem is wanting to remove the geographies with blanks in the matrix that I have. So instead of needing to scroll to the Geography, even though it is listed for it to just show the geographies that it is filtered by.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi,

        Thanks fot the solution Greg_Deckler  provided, and i want to offer some more information for user to refer to.

        hello MichaelaMul , based on your descriotion, you can try the following measure

        # of Accounts =
        IF (
            ISFILTERED ( Geography[Geography] ),
            CALCULATE ( COUNTROWS ( ( VALUES ( 'Salesperson Geos'[Geography] ) ) ) ),
            BLANK ()
        )
        

        If the soution cannot meet your requirement, can you provide some sample output you want? becasue you sadi you want to display some value in matrix, which field do you put into the row and column of matrix?

         

        Best Regards!

        Yolo Zhu

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