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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
sarthakgirdhar
Frequent Visitor

Help calculating past X years/semesters aggregate data and compare it to this years/semesters data.

Hello Power BI/DAX champions, 

I need your help with writing a DAX measure. I have a table that looks like this:-

Table.png

I have student grades across multiple semesters. If I simply do an aggregate of student grades across semesters, it looks something like this (semester_code 202410 translates to 2023/2024 Fall) :- 

Course Grades.png

The semester code values are 201710, 201720, 201730, 201810, 201820,...,202330, 202410, 202420.

What I now want is to write a DAX measure such that I have aggregated student grades for the last few semesters so that I can compare it with the most recent results. 

Thank you!

1 ACCEPTED SOLUTION

Hi @Anonymous (Wisdom Wu), 

I very much appreciate your help. This isn't exactly what I was hoping for; although, I did resolve it in a very similar manner as how you did it 🙂

Thanks and regards,
Sarthak Girdhar

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @sarthakgirdhar ,

Based on my testing, please try the following methods:

1.Create the sample table.

vjiewumsft_0-1720086833347.png

2.Create the new column and change the type to number.

Column = LEFT('Table'[semester_code], 4)

vjiewumsft_1-1720086843726.png

3.Create the new measure to filter the column.

Past = 
var _max = MAX('Table 2'[Semester])
RETURN
CALCULATE(
        COUNT('Table'[course_grade]),
        FILTER(
            ALLEXCEPT('Table','Table'[semester_code], 'Table'[course_grade]),
            'Table'[Column] < _max
        )
    )
Current = 
var _max = MAX('Table 2'[Semester])
RETURN
CALCULATE(
        COUNT('Table'[course_grade]),
        FILTER(
            ALLEXCEPT('Table','Table'[semester_code], 'Table'[course_grade]),
            'Table'[Column] = _max
        )
    )

4.Drag the measure into the table visual. The result is shown below.

vjiewumsft_2-1720086858922.png

vjiewumsft_3-1720086895256.png

Best Regards,

Wisdom Wu

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

Hi @Anonymous (Wisdom Wu), 

I very much appreciate your help. This isn't exactly what I was hoping for; although, I did resolve it in a very similar manner as how you did it 🙂

Thanks and regards,
Sarthak Girdhar

Anonymous
Not applicable

Hi @sarthakgirdhar ,

I am glad you have solved the problem. Please consider Accept it as the solution to help the other members find it more quickly.

 

Best Regards,

Wisdom Wu

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.