Forum Discussion
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
| Geography | Time | Product | Brand | Category | Entire Category | Volume Share |
| North | Last 4 Weeks | Group Apple | Apple | 100 | ||
| North | Last 4 Weeks | Product Red Apple | Our Brand Apple | Apple | 80 | |
| North | Last 4 Weeks | Product Green Apple | Green Apple | Apple | 20 | |
| North | Last 4 Weeks | Group Grape | Grape | 100 | ||
| North | Last 4 Weeks | Product Purple Grape | Our Brand Grape | Grape | 40 | |
| North | Last 4 Weeks | Product Green Grape | Green Grape | Grape | 60 | |
| North | Last 13 Weeks | Group Apple | Apple | 100 | ||
| North | Last 13 Weeks | Product Red Apple | Our Brand Apple | Apple | 45 | |
| North | Last 13 Weeks | Product Green Apple | Green Apple | Apple | 55 | |
| North | Last 13 Weeks | Group Grape | Grape | 100 | ||
| North | Last 13 Weeks | Product Purple Grape | Our Brand Grape | Grape | 30 | |
| North | Last 13 Weeks | Product Green Grape | Green Grape | Grape | 70 | |
| South | Last 4 Weeks | Group Apple | Apple | 100 | ||
| South | Last 4 Weeks | Product Red Apple | Our Brand Apple | Apple | 60 | |
| South | Last 4 Weeks | Product Green Apple | Green Apple | Apple | 40 | |
| South | Last 4 Weeks | Group Grape | Grape | 100 | ||
| South | Last 4 Weeks | Product Purple Grape | Our Brand Grape | Grape | 35 | |
| South | Last 4 Weeks | Product Green Grape | Green Grape | Grape | 65 | |
| South | Last 13 Weeks | Group Apple | Apple | 100 | ||
| South | Last 13 Weeks | Product Red Apple | Our Brand Apple | Apple | 56 | |
| South | Last 13 Weeks | Product Green Apple | Green Apple | Apple | 44 | |
| South | Last 13 Weeks | Group Grape | Grape | 100 | ||
| South | Last 13 Weeks | Product Purple Grape | Our Brand Grape | Grape | 75 | |
| South | Last 13 Weeks | Product Green Grape | Green Grape | Grape | 25 | |
| West | Last 4 Weeks | Group Apple | Apple | 100 | ||
| West | Last 4 Weeks | Product Red Apple | Our Brand Apple | Apple | 70 | |
| West | Last 4 Weeks | Product Green Apple | Green Apple | Apple | 30 | |
| West | Last 4 Weeks | Group Grape | Grape | 100 | ||
| West | Last 4 Weeks | Product Purple Grape | Our Brand Grape | Grape | 55 | |
| West | Last 4 Weeks | Product Green Grape | Green Grape | Grape | 45 | |
| West | Last 13 Weeks | Group Apple | Apple | 100 | ||
| West | Last 13 Weeks | Product Red Apple | Our Brand Apple | Apple | 30 | |
| West | Last 13 Weeks | Product Green Apple | Green Apple | Apple | 70 | |
| West | Last 13 Weeks | Group Grape | Grape | 100 | ||
| West | Last 13 Weeks | Product Purple Grape | Our Brand Grape | Grape | 60 | |
| West | Last 13 Weeks | Product Green Grape | Green Grape | Grape | 40 | |
| East | Last 4 Weeks | Group Apple | Apple | 100 | ||
| East | Last 4 Weeks | Product Red Apple | Our Brand Apple | Apple | 65 | |
| East | Last 4 Weeks | Product Green Apple | Green Apple | Apple | 35 | |
| East | Last 4 Weeks | Group Grape | Grape | 100 | ||
| East | Last 4 Weeks | Product Purple Grape | Our Brand Grape | Grape | 70 | |
| East | Last 4 Weeks | Product Green Grape | Green Grape | Grape | 30 | |
| East | Last 13 Weeks | Group Apple | Apple | 100 | ||
| East | Last 13 Weeks | Product Red Apple | Our Brand Apple | Apple | 40 | |
| East | Last 13 Weeks | Product Green Apple | Green Apple | Apple | 60 | |
| East | Last 13 Weeks | Group Grape | Grape | 100 | ||
| East | Last 13 Weeks | Product Purple Grape | Our Brand Grape | Grape | 64 | |
| East | Last 13 Weeks | Product Green Grape | Green Grape | Grape | 36 |
Geography Table
| Geography | ImageURL |
| North | example 1 |
| West | example 2 |
| South | example 3 |
| East | example 4 |
Salesperson Geos Table
| Manager | Geography |
| Joe | North |
| Joe | West |
| Harry | South |
| Harry | East |
3 Replies
- Greg_DecklerCommunity 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?
- MichaelaMulHelper 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.
- AnonymousNot 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.