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

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

Reply
JL_091484
New Member

Cumulative sum for a previous day's data

Hi all

 

I'm displaying some sales figuers by hour for a given day in a table with both hourly and cumulative numbers, I've been able to get numbers for the day before using 

 

 

YD rev = 
var yesterday = max('Retail Caldender'[Date]) - 1
var amount = CALCULATE(SUM('Actuals TY'[ConvertedRev]),FILTER(ALL('Retail Caldender'),'Retail Caldender'[Date] = yesterday))
return
amount

 

and a cumualtive number for the sleected day using 

 

Cumulative demand TY hour = if([Demand Local conversion]=0,
         "",
         CALCULATE('Actuals TY'[Demand Local conversion],
                FILTER(ALLSELECTED('Actuals TY'),
                      'Actuals TY'[hourtime]<= MAX('Actuals TY'[hourtime])
                      )
                       )
                        )

 

 

But I can't seem to get a cumulative figute for the previous working, I've tried replacing [Demand Local Conversion] with my [YD rev], buidling it compeltly seperatly and looked online for other ways of calcualting a cumulative totlal but I can't seem to get it to work. 

 

Thanks in advance

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@JL_091484 , Try a measure with help from date table like

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date]) -1 ))

 

or

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date]) && Date[Date] < today() -1 ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
JL_091484
New Member

Hi @amitchandak 

 

Just changed it from 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date]) && Date[Date] < today() -1 ))

to 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date]) && Date[Date] = today() -1 ))

and it works

 

Thanks for your help

amitchandak
Super User
Super User

@JL_091484 , Try a measure with help from date table like

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date]) -1 ))

 

or

 

Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(all('Date'),'Date'[date] <=max('Date'[date]) && Date[Date] < today() -1 ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

I've tried to adapt it for my tables

 

Cumulative demand YD hour = 
CALCULATE(
    SUM('Actuals TY'[ConvertedRev]),
      FILTER(ALL('Actuals TY'),'Actuals TY'[hourtime]<=MAX('Actuals TY'[hourtime]) && 'Actuals TY'[dateofpur] <TODAY()-1))

 

It works for a cumulative sum but appears to be summing across the whole date range rather than one day. I tried ALLSELECTED but then it is blank. 

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors