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
JoRo50
Frequent Visitor

Creating Dax code to dynamically calculate a "Not Group" value based on multiple slicers

Special shout out to @AUaero  for helping out with the foundation for this problem (https://community.powerbi.com/t5/Desktop/calculation-to-show-value-for-NOT-variable/m-p/2665613) by showing me how to create a "not selected" calculation so that I can compare ingroup rates to out of group rates for a metric and allowing those rates to be filtered by ONE slicer.

 

I am now trying to expand this effort so that the calculation can be filtered by more than one filter.  I want to build a Matrix table that shows the student completion rate based on faculty tenure status and compare to the completion rates for other faculty statuses combined.  Furthermore, these rates should dynamically adjust based on Division selected and Student Gender.

 

For instance, I'm creating a table where I want to see the rates of student completion for Adjunct instructors within the Humanities Division for female students compared to the completion rates for Full time and Tenured instructors within the Humanities Division for female students.

 

Division SlicerHumanities  
Student Gender SlicerF  
    
Row LabelsGroup rateNonGroup Rate 
Adjunct88%82%non group rate includes non-Adjunct, Humanities instructors, Female Students
FT, Not Tenured83%83%non group rate includes non-"FT, Not Tenured", Humanities instructors, Female Students
Tenure81%85%

non group rate includes non-Tenured, Humanities instructors, Female Students

 

This is an example of my data:

Instructor StatusDivisionStudent GenderEnrolledTaskComplete
AdjunctHumanitiesF8070
AdjunctHumanitiesM6560
AdjunctHumanitiesO43
FT, Not TenuredHumanitiesF120100
FT, Not TenuredHumanitiesM110100
FT, Not TenuredHumanitiesO31
TenureHumanitiesF160130
TenureHumanitiesM180135
TenureHumanitiesO62
AdjunctSTEMF6040
AdjunctSTEMM8070
AdjunctSTEMO21
FT, Not TenuredSTEMF4340
FT, Not TenuredSTEMM7570
FT, Not TenuredSTEMO00
TenureSTEMF7560
TenureSTEMM12080
TenureSTEMO32

 

Ideally, the solution should work if only one or no slicers are selected as well.  I can create one or the other of these next two examples using the solution provided by @AUaero , but the calculation gets funky if more than one slicer is selected.

Division SlicerHumanities  
Student Gender Slicer   
    
Row LabelsGroup rateNonGroup Rate 
Adjunct89%81%non group rate includes non-Adjunct, Humanities instructors, all Genders
FT, Not Tenured86%81%non group rate includes non-"FT, Not Tenured", Humanities instructors, all Genders
Tenure77%87%non group rate includes non-Tenured, Humanities instructors, all Genders

 

or 

 

Division Slicer   
Student Gender SlicerFemale  
    
Row LabelsGroup rateNonGroup Rate 
Adjunct79%83%non group rate includes non-Adjunct, instructors from all Divisions, Female Students
FT, Not Tenured86%80%non group rate includes non-"FT, Not Tenured", instructors from all Divisions, Female Students
Tenure81%83%non group rate includes non-Tenured, instructors from all Divisions, Female Students

 

This is the example if no slicers are selected.  Here the solution would compare outcomes for all Divisions and students.  

Division Slicer   
Student Gender Slicer   
    
Row LabelsGroup rateNonGroup Rate 
Adjunct84%80%non group rate includes non-Adjunct, instructors from all Divisions, all Gender Students
FT, Not Tenured89%78%non group rate includes non-"FT, Not Tenured", instructors from all Divisions, all Genders
Tenure75%86%non group rate includes non-Tenured, instructors from all Divisions, all Genders

 

 

In all of these cases, we are comparing each tenure status category with all of the other tenure status categories.

 

Thank you in advance for your brilliant solutions.

 

-J

1 ACCEPTED SOLUTION
AUaero
Responsive Resident
Responsive Resident

Thanks for the shoutout, @JoRo50!  I loaded your sample data and was able to get the results you specified in your examples with these measures:

% Completion = 
VAR SumEnrolled = SUM('SampleData'[Enrolled])
VAR SumTaskComplete = SUM('SampleData'[TaskComplete])

RETURN
DIVIDE(SumTaskComplete, SumEnrolled)
% Complete - Non-Group Rate = 
VAR ThisInstructorStatus = MAX(SampleData[InstructorStatus])

RETURN 
CALCULATE(
    [% Completion],
    FILTER(
        ALLEXCEPT(SampleData, SampleData[Division], SampleData[StudentGender]),
        NOT(SampleData[InstructorStatus] = ThisInstructorStatus)
    )
)

Does this get you what you are looking for?

View solution in original post

2 REPLIES 2
JoRo50
Frequent Visitor

@AUaero Thank you.  It was a simple solution but required tweaking your original solution.  I had been using various other charachters to link my filters that I found in other online solutions but they didn't work.

AUaero
Responsive Resident
Responsive Resident

Thanks for the shoutout, @JoRo50!  I loaded your sample data and was able to get the results you specified in your examples with these measures:

% Completion = 
VAR SumEnrolled = SUM('SampleData'[Enrolled])
VAR SumTaskComplete = SUM('SampleData'[TaskComplete])

RETURN
DIVIDE(SumTaskComplete, SumEnrolled)
% Complete - Non-Group Rate = 
VAR ThisInstructorStatus = MAX(SampleData[InstructorStatus])

RETURN 
CALCULATE(
    [% Completion],
    FILTER(
        ALLEXCEPT(SampleData, SampleData[Division], SampleData[StudentGender]),
        NOT(SampleData[InstructorStatus] = ThisInstructorStatus)
    )
)

Does this get you what you are looking for?

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.

Top Solution Authors