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
andy291086
Frequent Visitor

DAX Logic for Calculating Rolling Sum

Hi Team, 

 

I am new to Power BI and DAX. I had been assigned to convert an Excel report into Power BI which has the following calculations. 

andy291086_3-1701067108832.png

 

I am stuck up with the calculations for Behind , which is based on the excel formula , Prior Behind Days + ( Target Days - Rolling Average Days) / Weeks left. Behind Days for Week 1 is 0 . 

 

For .e,g, for Week 3, the behind is calculated as 0.5 + (350 - 295.67)/49 = 1.6, 

 

Can you please help ?

 

Cheers, 

Andy

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @andy291086 ,

I created a sample pbix file(see the attachment) for you, please check if that is what you want.

Week Number = VALUE(RIGHT('Table'[Week], LEN('Table'[Week]) - 5))
Column = 
VAR _preweek =
    CALCULATE (
        MAX ( 'Table'[Week Number] ),
        FILTER ( 'Table', 'Table'[Week Number] < EARLIER ( 'Table'[Week Number] ) )
    )
VAR _prewbdays =
    CALCULATE (
        MAX ( 'Table'[Behind Days] ),
        FILTER ( 'Table', 'Table'[Week Number] = _preweek )
    )
RETURN
    _prewbdays + ( 'Table'[Target Days] - [Rolling Average - Days] ) / 'Table'[Weeks Left]

vyiruanmsft_0-1701238156100.png

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @andy291086 ,

I created a sample pbix file(see the attachment) for you, please check if that is what you want.

Week Number = VALUE(RIGHT('Table'[Week], LEN('Table'[Week]) - 5))
Column = 
VAR _preweek =
    CALCULATE (
        MAX ( 'Table'[Week Number] ),
        FILTER ( 'Table', 'Table'[Week Number] < EARLIER ( 'Table'[Week Number] ) )
    )
VAR _prewbdays =
    CALCULATE (
        MAX ( 'Table'[Behind Days] ),
        FILTER ( 'Table', 'Table'[Week Number] = _preweek )
    )
RETURN
    _prewbdays + ( 'Table'[Target Days] - [Rolling Average - Days] ) / 'Table'[Weeks Left]

vyiruanmsft_0-1701238156100.png

Best Regards

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.