Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
speedramps
Super User
Super User

Shows the row percentage of the cohort total.

A question for DAX gurus please ......

 

See the attached example PBIX for a vet’s visits.

PBIX example

 

It has 3 matrix style reports each with members of a cohort

  • Species by Location
  • Breed by Species
  • Reason by Species

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

 

 

1 ACCEPTED SOLUTION
themistoklis
Community Champion
Community Champion

@speedramps 

 

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 )

View solution in original post

2 REPLIES 2
themistoklis
Community Champion
Community Champion

@speedramps 

 

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.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.