Forum Discussion

Brendy_P's avatar
Brendy_P
Helper I
4 years ago
Solved

Running Totals

Hi 

I have the solution but want to understand the logic of the solution, below is the formula with the logic of what I think the formula is performing. Can someone correct me in understanding the logic or am I correct.

 

Running Total (Filter) =
CALCULATE([Sales],
FILTER(ALL(Full_Date_Table),-- We are going to filter the full dates table but before we do make sure all the filters are cleared
Full_Date_Table[Date]>MAX(Full_Date_Table[Date])-30&&-- If the date in the filter context is > to the date(s) of the Max date in the filter context then go back 30 days (MAX is a scalar Function) AND
Full_Date_Table[Date]<=MAX(Full_Date_Table[Date]))) -- If the date in the filter context is <= to Max date in the filter context then Calculate sales
 
I know I can create the same formula with 
Running Totals (DatesInPeriod) =
CALCULATE([Sales],
DATESINPERIOD(Full_Date_Table[Date],
MAX(Full_Date_Table[Date]),-30,DAY))
 
But I want to get my head around how the first formula works. 
Thanks for your time

2 Replies