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.
A question for DAX gurus please ......
See the attached example PBIX for a vet’s visits.
It has 3 matrix style reports each with members of a cohort
with slicers for Species, Breed, Reason and Location
I want to add a callout % to each report which shows the row member percentage of the cohort total.
For example, on the Species by location the Glasgow cohort total is 139 so the callout % will be
Bird | 38 | 27.34% |
Cat | 49 | 35.25% |
Dog | 29 | 21.86% |
Fish | 23 | 17.55% |
Total | 139 |
|
I have created the following measure on the Species by Location report which uses ALL command to override the row context.
Total quantity for location = CALCULATE([Total quantity], ALL('Vet Callouts'[Species]))
% Callout = DIVIDE([Total quantity], [Total quantity for location], BLANK())
However, the ALL command does not distinguish the difference between the Row Context and the Table Context.
So if I use the slicer to remove the 49 Cats member the Glasgow cohort total should be 90 not 139 and the callout % should be
Bird | 38 | 42% |
Dog | 29 | 32% |
Fish | 23 | 26% |
Total | 90 |
|
How do I do that?
And is there is a quick way to do it for each report?
Many thanks
Solved! Go to Solution.
Change the formula to this and it will work
Total quantity for location =
CALCULATE(
[Total quantity],
ALLSELECTED('Vet Callouts'[Species])
)
Depending on your regional settings change comma(,) to semicolon(;)
OR add this to the percentage column:
% Share =
VAR Volume =
SUM('Vet Callouts'[Quantity])
VAR AllVolume =
CALCULATE ( SUM('Vet Callouts'[Quantity]),ALLSELECTED('Vet Callouts'[Species]) )
RETURN
DIVIDE ( Volume, AllVolume )
Change the formula to this and it will work
Total quantity for location =
CALCULATE(
[Total quantity],
ALLSELECTED('Vet Callouts'[Species])
)
Depending on your regional settings change comma(,) to semicolon(;)
OR add this to the percentage column:
% Share =
VAR Volume =
SUM('Vet Callouts'[Quantity])
VAR AllVolume =
CALCULATE ( SUM('Vet Callouts'[Quantity]),ALLSELECTED('Vet Callouts'[Species]) )
RETURN
DIVIDE ( Volume, AllVolume )
Many thanks themistoklis
ALLSELECTED is exactly what I wanted. This function is different from ALL() because it retains all filters explicitly set within the query, and it retains all context filters other than row and column filters.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
107 | |
97 | |
75 | |
63 | |
53 |
User | Count |
---|---|
139 | |
100 | |
95 | |
85 | |
63 |