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
iansimpson888
Regular Visitor

creating a rolling average

Hi, i have a table displaying the weekly average attendance of a student:

 

iansimpson888_0-1683659695883.png

 

It is calculated using a 'rolling' average, so:

week 1 actual (05/09/2022) = 100%

week 1 rolling (05/09/2022) = 100%

week 2 actual (12/09/2022) = 90%

week 2 rolling (12/09/2022) = 95% (100+90 = 190, /2  = 95%)

week 3 actual (19/09/2022) = 100%

week 3 rolling (19/09/2022) = 96.67% (100+90+100= 290, /3  = 96.67%)

 

The DAX for this measure is:

 

Weekly % Attendance (Rolling) =

AVERAGEX(

    FILTER( ALLSELECTED( 'powerbi_attendance_weekly_average' ),

        'powerbi_attendance_weekly_average'[Mark Date (Weeks DD/MM/YY)] <= MAX (powerbi_attendance_weekly_average[Mark Date (Weeks DD/MM/YY)])),            'powerbi_attendance_weekly_average'[Weekly % Attendance])

 

This seems to work fine in a PBI table when the table is filtered to a single student, as above, but when I try to display multiple students, this is the result:

 

iansimpson888_1-1683659695885.png

 

I suspect the value is a combined value for all students. These are fictitious names, I should add.

Hope somebody can give me some pointers with this, many thanks

 

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @iansimpson888 ,

 

I suggest you to try ALL() and add [Full Name] column into filter code part.

Weekly % Attendance (Rolling) =
AVERAGEX (
    FILTER (
        ALL ( 'powerbi_attendance_weekly_average' ),
        'powerbi_attendance_weekly_average'[Mark Date (Weeks DD/MM/YY)]
            <= MAX ( powerbi_attendance_weekly_average[Mark Date (Weeks DD/MM/YY)] )
            && 'powerbi_attendance_weekly_average'[Full Name]
                = MAX ( 'powerbi_attendance_weekly_average'[Full Name] )
    ),
    'powerbi_attendance_weekly_average'[Weekly % Attendance]
)

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @iansimpson888 ,

 

I suggest you to try ALL() and add [Full Name] column into filter code part.

Weekly % Attendance (Rolling) =
AVERAGEX (
    FILTER (
        ALL ( 'powerbi_attendance_weekly_average' ),
        'powerbi_attendance_weekly_average'[Mark Date (Weeks DD/MM/YY)]
            <= MAX ( powerbi_attendance_weekly_average[Mark Date (Weeks DD/MM/YY)] )
            && 'powerbi_attendance_weekly_average'[Full Name]
                = MAX ( 'powerbi_attendance_weekly_average'[Full Name] )
    ),
    'powerbi_attendance_weekly_average'[Weekly % Attendance]
)

 

Best Regards,
Rico Zhou

 

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

 

Greg_Deckler
Community Champion
Community Champion

@iansimpson888 Drop your ALLSELECTED.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.