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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
alan19
Frequent Visitor

Running total

I need help with calculating running total for cales column on three basis, daily, weekly and monthly. and to always the starting point move forward as for daily 365 days from today, weekly 52 weeks from current week and monthly 12 months from current month. I have the following measures that start from the first available date always, how can i add above conditions?

Daily RT =
VAR MaxDate = MAX ( 'Date'[Date] )
RETURN
    CALCULATE (
        [Total Sales],          
        'Date'[Date] <= MaxDate,  
        ALL ( 'Date' )              
    )
 
 
Weekly RT =
VAR MaxDate = MAX ( 'Date'[Week Start] )
RETURN
    CALCULATE (
        [Total Sales],            
        ALL ( 'Date'),
        'Date'[Week Start] <= MaxDate
    )
Monthly RT =
VAR MaxDate = MAX ( 'Date'[Month Start] )
RETURN
    CALCULATE (
        [Total Sales],            
        ALL ( 'Date'),
        'Date'[Month Start] <= MaxDate
    )
2 REPLIES 2
alan19
Frequent Visitor

thatnk you so much for your answer. It was very helpful. Now using these to functions  though I can calculate the runnin totals monthly and weekly but when plot them in a line chart, the month turns into days when choosing days for X axis, How can i plot them in a line chart and lines remain monthly and daily each:  

RolleUp Month =
VAR Period =
DATESINPERIOD(
'Date'[Date],
MAX('Date'[Date]),
-12,
MONTH
)
VAR totalSales =
CALCULATE(
[Total Sales],
Period
)
RETURN
totalSales

 

RolleUp Day =
VAR Period =
DATESINPERIOD(
'Date'[Date],
MAX('Date'[Date]),
-365,
DAY
)
VAR TotalSales =
CALCULATE(
[Total Sales],
Period
)
RETURN
TotalSales

Greg_Deckler
Community Champion
Community Champion

@alan19 First, I would go with this format: (3) Better Running Total - Microsoft Fabric Community

So your first measure would be: 

 

Better Daily RT =
    VAR __Date = MAX('Date'[Date])
    VAR __MinDate = __Date - 365
    VAR __Table = 
      SUMMARIZE(
        FILTER(ALLSELECTED('Table'),[Date] <= __Date && [Date] >= __MinDate),
        [Date],
        "__TotalSales", [Total Sales]
      )
    VAR __Result = SUMX( __Table, [__TotalSales]
RETURN
  __Result

 

For Monthly this:

 

Better Monthly RT =
    VAR __Date = MAX('Date'[Date])
    VAR __PrevDate = EOMONTH( __Date, -12)
    VAR __MinDate = DATE(YEAR(__PrevDate), MONTH(__PrevDate), 1)
    VAR __Table = 
      SUMMARIZE(
        FILTER(ALLSELECTED('Table'),[Date] <= __Date && [Date] >= __MinDate),
        [Date],
        "__TotalSales", [Total Sales]
      )
    VAR __Result = SUMX( __Table, [__TotalSales]
RETURN
  __Result

 

For weekly, I recommmed using Sequential and then the format is almost exactly the same.

Sequential - 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.