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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Dnicetin
Helper I
Helper I

Calculating an average of scores whilst removing an outlier group of scores

Hi

I am wondering if anyone had some ideas on how I can solve this problem using a Dax formula (or a combination of Dax Formula's).

 

I get student satisfaction scores broken out into Classes and Instructor’s
Currently I look at the class average of the instructor as a metric

What I would like to do is look at the class average but remove the lowest scoring class from this metric

See attached sample data
e.g 1
Instructor 1 has 3 classes that have the following averages.
Class Number 4 with a class Average of 5.00
Class Number 3 with a class Average of 4.65
Class number 5 with a class Average of 4.86
I would like the calculation to only take into account the 5.00 and 4.86 Scores when calculating the Average

Eg2
Instructor 2 has 3 classes that have the following averages.
Class number 6 with a class Average of 5.0
Class Number 2 with a class Average of 4.38
Class number 1 with a class Average of 4.50
I would like the calculation to only take into account the 5.00 and 4.50 Scores when calculating the Average

 

Student NameinstructorClass Identifier NumberSatisfaction Score out of 5
Student #1Instructor 1Class Number 45
Student #2Instructor 1Class Number 45
Student #3Instructor 1Class Number 45
Student #4Instructor 1Class Number 45
Student #5Instructor 1Class Number 35
Student #6Instructor 1Class Number 35
Student #7Instructor 1Class Number 35
Student #8Instructor 1Class Number 33
Student #9Instructor 1Class Number 35
Student #10Instructor 1Class Number 34
Student #11Instructor 1Class Number 34
Student #12Instructor 1Class Number 35
Student #13Instructor 1Class Number 34
Student #14Instructor 1Class Number 35
Student #15Instructor 1Class Number 35
Student #16Instructor 1Class Number 35
Student #17Instructor 1Class Number 35
Student #18Instructor 1Class Number 34
Student #19Instructor 1Class Number 35
Student #20Instructor 1Class Number 35
Student #21Instructor 1Class Number 35
Student #22Instructor 1Class number 55
Student #23Instructor 1Class number 55
Student #24Instructor 1Class number 55
Student #25Instructor 1Class number 55
Student #26Instructor 1Class number 55
Student #27Instructor 1Class number 54
Student #28Instructor 1Class number 55
Student #29Instructor 2Class number 65
Student #30Instructor 2Class number 65
Student #31Instructor 2Class number 65
Student #32Instructor 2Class number 65
Student #33Instructor 2Class Number 25
Student #34Instructor 2Class Number 25
Student #35Instructor 2Class Number 23
Student #36Instructor 2Class Number 25
Student #37Instructor 2Class Number 25
Student #38Instructor 2Class Number 23
Student #39Instructor 2Class Number 25
Student #40Instructor 2Class Number 24
Student #41Instructor 2Class number 12
Student #42Instructor 2Class number 15
Student #43Instructor 2Class number 15
Student #44Instructor 2Class number 13
Student #45Instructor 2Class number 15
Student #46Instructor 2Class number 16
Student #47Instructor 2Class number 15
Student #48Instructor 2Class number 15

 

8 REPLIES 8
ThxAlot
Super User
Super User

A calculated table significantly simply the calculation.

ThxAlot_0-1698734617581.png

 

ThxAlot_1-1698734661671.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



wdx223_Daniel
Super User
Super User

AverageScore = AVERAGEX(VALUES(SampleTable[Class Identifier Number]),CALCULATE(AVERAGE(SampleTable[Satisfaction Score out of 5])))
AverageScoreRemoveLast1 = IF(COUNTROWS(VALUES(SampleTable[Class Identifier Number]))=1,[AverageScore],AVERAGEX(WINDOW(1,ABS,-2,ABS,VALUES('SampleTable'[Class Identifier Number]),ORDERBY([AverageScore],DESC)),[AverageScore]))
wdx223_Daniel_0-1698733343629.png

 

thanks again for your work on this...

 

this looks like its coming together. but it stops at the (WINDOW section in the formula  😞

FreemanZ
Super User
Super User

hi @Dnicetin ,

 

try to plot a table visual with [instructor] column and a measure like:

 

AvgTop2 = 
VAR _table =
    ADDCOLUMNS(
        SUMMARIZE(data, data[instructor], data[Class]),
        "Avg",
        CALCULATE(AVERAGE(data[Score]))
    )
VAR result = 
    CALCULATE(
        AVERAGEX(
            TOPN(2, _table, [Avg]),
            [Avg]
        )
    )
RETURN result

 

 

it worked like:

FreemanZ_0-1698716256485.png

 

thanks for that.

I guess my challenge is its not always just three classes (sorry i had a bad example)

The number of classes is variable

the proposed measure will always average on the top2, no matter how many classes each instructor has. just try with your original data and let us know the result. 

i dont understand that format sorry. Just know how to create Measures on all my sheet's.

I have tried to convert it but its not liking the "VAR" onwards part (as i suspect its telling it to create something it doesnt undersand)

the code is also good for measures used in Excel Pivot table. 

 

FreemanZ_0-1698733119615.png

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors