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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
unknown_anony
Helper II
Helper II

How to calculate the rolling sum of each month headcount?

Hello ,
I am trying to work on the rolling sum of the total headcoun,
Following is the dax query  i have written

MOM_engadd = VAR A = CALCULATE(SUM('Estimate Table'[Eng Addition]),ALL('Estimate Table'[Date]),
'Estimate Table'[Date]>MAX('Estimate Table'[Date])-30 &&
'Estimate Table'[Date]<=MAX('Estimate Table'[Date]))
RETURN
A

Estimate is the table name and i am counting the number  of people added every month on a cummulative basis but it is not working 

unknown_anony_0-1724063899853.png

Kindly advice
Thank you



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @unknown_anony ,
Thanks for  Greg_Deckler reply.
Here is a measure you can try

rolling total = 
IF(
    'Table'[Value] = 0,
    0,
    CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            'Table',
            'Table'[Date] <= EARLIER('Table'[Date])
        )
    )
)

Final output

vheqmsft_0-1724131149419.png

 

Best regards,
Albert He


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
Anonymous
Not applicable

Hi @unknown_anony ,
Thanks for  Greg_Deckler reply.
Here is a measure you can try

rolling total = 
IF(
    'Table'[Value] = 0,
    0,
    CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            'Table',
            'Table'[Date] <= EARLIER('Table'[Date])
        )
    )
)

Final output

vheqmsft_0-1724131149419.png

 

Best regards,
Albert He


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

 

Greg_Deckler
Super User
Super User

@unknown_anony Try this but use SUMX instead of AVERAGEX: Better Rolling Average - Microsoft Fabric Community



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

i do want to average, i want to sum the headcounts monthly basis,
for ex:-
Old column                new column
Jan 2024 - 16         Jan 2024 - 16
Feb 2024 - 0           Feb 2024 - 0
Mar 2024 - 2           Mar 2024 - 18
Apr 2024 - 4            Apr 2024 - 22

so on and so forth

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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