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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
WJ876400
Helper IV
Helper IV

Calculating Average

Hello

 

I have a dataset of students and the units they are undertaking and then the grade for that unit. What i want to achieve is an average mark for the students class, so the unit will be repeated each year and I need to single out the average for the class for that year. I have done a rough idea of the data below, you can see the unit Test 1 runs over 3 years but I need to know the average mark for each year. Each student has their own ID and the unit has its own ID for each year.

 

Unit NameYearGradeID
Test 119/2050123
Test 120/2160234
Test 121/2270456
Test 121/2271888
Test 121/2275999
Test 221/2291567
Test 221/2225111
Test 221/2265222
Test 321/2270891
Test 421/2282910

 

hopefully that makes sens, any help is appreciated, thanks

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @WJ876400 

 

You can try the following methods.

Column:

Column =
CALCULATE (
    AVERAGE ( 'Table'[Grade] ),
    FILTER (
        'Table',
        [Year] = EARLIER ( 'Table'[Year] )
            && [Unit Name] = EARLIER ( 'Table'[Unit Name] )
    )
)

vzhangti_0-1662621346567.png

 

Measure:

Measure =
CALCULATE (
    AVERAGE ( 'Table'[Grade] ),
    ALLEXCEPT ( 'Table', 'Table'[Year], 'Table'[Unit Name] )
)

vzhangti_1-1662621424334.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-zhangti
Community Support
Community Support

Hi, @WJ876400 

 

You can try the following methods.

Column:

Column =
CALCULATE (
    AVERAGE ( 'Table'[Grade] ),
    FILTER (
        'Table',
        [Year] = EARLIER ( 'Table'[Year] )
            && [Unit Name] = EARLIER ( 'Table'[Unit Name] )
    )
)

vzhangti_0-1662621346567.png

 

Measure:

Measure =
CALCULATE (
    AVERAGE ( 'Table'[Grade] ),
    ALLEXCEPT ( 'Table', 'Table'[Year], 'Table'[Unit Name] )
)

vzhangti_1-1662621424334.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@WJ876400 , Sone of the two

 

AverageX(Values(Table[Year]) , Calculate(Sum(Table[Grade])) )

 

or

 

AverageX(Summarize(Table,Table[Year], Table[Unit Name]) , Calculate(Sum(Table[Grade])) )

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Thank you for the response, sorry do I do this in the query editor or add it as a new measure or column?

 

thanks

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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