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
summer18
Helper III
Helper III

Running total by last N weeks

I currently have running total formula which works but I would also need to get the running total for last 7 weeks.  Can someone please help me on this formula?

 

Here's my formula for Running Total which works:

 
Running total in Sales =
CALCULATE(SUM('Sales'[sales_amount]),
    FILTER(
        ALLSELECTED('Date'[Week]),
        ISONORAFTER('Date'[Week], MAX('Date'[Week]), DESC)
    ))
 
 

 

1 ACCEPTED SOLUTION

Hi @summer18 

Create a column

index1 = INT(([Week]-1)/7)

Create a measure

Measure =
CALCULATE (
    SUM ( 'Table 2'[sale amount] ),
    FILTER (
        ALLSELECTED ( 'Table 2' ),
        'Table 2'[Year] = MAX ( 'Table 2'[Year] )
            && 'Table 2'[Week] <= MAX ( 'Table 2'[Week] )
            && 'Table 2'[index1] = MAX ( 'Table 2'[index1] )
    )
)

Capture7.JPGCapture8.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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
amitchandak
Super User
Super User

@summer18 , Try one of these two

 

Running total in Sales =
CALCULATE(SUM('Sales'[sales_amount]),
    FILTER(
        ALLSELECTED('Date'[Week]),
        'Date'[Week]<= MAX('Date'[Week]) &&
		 'Date'[Week]>= MAX('Date'[Week])-7
    ))
	
Running total in Sales =
CALCULATE(SUM('Sales'[sales_amount]),
    FILTER(
        ALL('Date'[Week]),
        'Date'[Week]<= MAX('Date'[Week]) &&
		'Date'[Week]<= MAX('Date'[Week]) -7
    ))

 

Refer to my blog on Week

https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak ,

The running total works if it's the same month so when it's different month the running total resets.  

 

The expected output is the highlighted green column:

 

pic1.jpg

Hi @summer18 

Create a column

index1 = INT(([Week]-1)/7)

Create a measure

Measure =
CALCULATE (
    SUM ( 'Table 2'[sale amount] ),
    FILTER (
        ALLSELECTED ( 'Table 2' ),
        'Table 2'[Year] = MAX ( 'Table 2'[Year] )
            && 'Table 2'[Week] <= MAX ( 'Table 2'[Week] )
            && 'Table 2'[index1] = MAX ( 'Table 2'[index1] )
    )
)

Capture7.JPGCapture8.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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! Prices go up Feb. 11th.

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.