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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jsbourni
Helper I
Helper I

Fixed average regardless of filters

Hi,

 

I'm playing with school data like this:

YearSemesterCycleDepartmentCourseEnrolled
2018-2019Winter11X1236
2018-2019Fall11X23412
2018-2019Summer11X34534
2018-2019Winter11X45645
2018-2019Fall11X56723
2018-2019Summer11X67832
2018-2019Winter11X78921
2018-2019Fall11X90016
2018-2019Summer21X101133
2018-2019Winter21X112226
2018-2019Fall21X123324
2018-2019Summer21X134412
2018-2019Winter21X145512
2018-2020Fall21X156630
2018-2021Summer21X167723

 

I'm trying to set a fixed average per cycle per year to compare the average number of student enrolled per course per year to the grand mean per cycle and, ultimately, count the number of courses per department or by cycle (one visualisation each) that are under the (rounddown)mean per cycle.

The problem I have is that I can't set the fixed value for the cycle mean, it is always dependant on the variables in the visualisations. One thing I should mention is that some filters have to be added to the visualisations as not all the data should be used to do the calculations. Hence the alternate idea of creating a table with dynamically-set means per cycle.

The desired output should (I think) look like this:

yearCycleDepartmentMean per cycleNb of courses under
2018-20191123.64 or 50%
2018-20192122.92 or 29%

This would allow to create a visualisation by cycle and another by department (using small multiples).

 

I created a measure for the mean per cycle, but if I add the department in the visualisation, everything changes:

Cycle mean = CALCULATE(AVERAGE(DATA[Enrolled]), DATA[Credits]<>0, DATA[Enrolled]<>0)

Givent that, I tried to calculate the number of courses under the mean but did not come close to anything, most of the time it returns blank cells.

I tried to do this all at once in a single measure, but maybe this is not the appropriate way.

Would take any advice. Thanks,

1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

@jsbourni 

You can use ALLEXCEPT to remove filters from a calcualtion so it looks at more data than just the rows it is on.

Cycle Mean = 
CALCULATE (
    AVERAGE ( DATA[Enrolled] ),
    DATA[Enrolled] <> 0,
    ALLEXCEPT ( DATA, DATA[Year], DATA[Cycle] )
)

Then we can use that measure to count the courses that are under on Enrolled.

Courses Under = 
COUNTROWS(
    FILTER(DATA,DATA[Enrolled]<[Cycle Mean])
)

jdbuchanan71_0-1671202579893.png

I have attached my sample file for you to look at.

 

 

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

@jsbourni 

You can use ALLEXCEPT to remove filters from a calcualtion so it looks at more data than just the rows it is on.

Cycle Mean = 
CALCULATE (
    AVERAGE ( DATA[Enrolled] ),
    DATA[Enrolled] <> 0,
    ALLEXCEPT ( DATA, DATA[Year], DATA[Cycle] )
)

Then we can use that measure to count the courses that are under on Enrolled.

Courses Under = 
COUNTROWS(
    FILTER(DATA,DATA[Enrolled]<[Cycle Mean])
)

jdbuchanan71_0-1671202579893.png

I have attached my sample file for you to look at.

 

 

That is very close, thanks. I don't know why, the addition of Department on my side (in my pbix) still changes the cycle mean.

If I wanted the proportion of courses under the mean, should I wrap your measure in a DIVIDE formula?

Thank you again

 

EDIT: works like a charm, my bad

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.