Hi All, I’m working on a report to calculate a yearly running total between two specific date range; the second Monday in September and January 31st of the next year, and want it to be dynamic for coming years.
I’m presently using this code for the Running Total.
Running Total For The Season ($) = TOTALYTD( SUM(Seasonal[Amount ($)]), 'Date'[Date], 'Date'[Month] = 9 || 'Date'[Month] = 10 || 'Date'[Month] = 11 || 'Date'[Month] = 12 || 'Date'[Month] = 1, "1/31" )
How tied are you to the DAX CALENDARAUTO Date Table that you are using? If you were open to switching over to @Melissa 's awesome Extended Date Table, it would make this analysis a snap.
The main reason is that there’s a nested group manipulation I’d like to do in Power Query that will make this really easy, and that can only be done with physical tables not DAX calculated tables.
I’ll go ahead and put together a solution on this based on that approach. I just wanted to check with you first to make sure that changing the Dates table wasn’t a non-starter for you.
Okay, even with the Extended Date Table this ended up being far from a snap, but I think without that table it would’ve been damn near impossible. I ended up using a three-step process:
added a custom column index to count the nested table rows in order to identify the second Monday in September
build out the following DAX measure. Ended up being quite challenging to get the context correct with the year crossing the December to January line and still picking up the January dates while getting the cumulative function to reset each February 1. Here’s the measure that does the heavy lifting:
Cumul Seasonal2 =
VAR CurrYr = SELECTEDVALUE( Dates[FY 4Digit] )
VAR Result =
CALCULATE(
[Total Amount],
FILTER(
ALL(Dates),
Dates[Date] >= [Second September] &&
Dates[Date] <= [End of Jan Next Year] &&
Dates[Date] <= MAX( Dates[Date] ) &&
Dates[FY 4Digit] = CurrYr
)
)
VAR FiltResult =
IF(
SELECTEDVALUE( Dates[Date] )>= [Second September] &&
SELECTEDVALUE(Dates[Date]) <= [End of Jan Next Year],
Result,
BLANK()
)
RETURN FiltResult
Here’s what it looks like all put together:
I hope this is helpful. Full solution file attached below.