Hi @Nurry90,
There seems to be an issue with your Date table that you’ll need to look into and fix. Your FY start month is July but June 2019 is now seen BEFORE July 2019 and not AFTER May 2019.
Nevertheless I worked around that by creating a custom index for your EOM logic. By adding this Calculated Column to your Date table.
EOM ID =
VAR cFYFW = 'Date Table'[FYWeeknYear]
VAR vTableA =
FILTER(
ALL('Date Table'[FYWeeknYear], 'Date Table'[EOMLogic] ),
'Date Table'[FYWeeknYear] <= cFYFW &&
'Date Table'[EOMLogic] <> "EOM"
)
VAR vTableB =
FILTER(
ALL('Date Table'[FYWeeknYear], 'Date Table'[EOMLogic] ),
'Date Table'[FYWeeknYear] <= cFYFW &&
'Date Table'[EOMLogic] = "EOM"
)
VAR vTable = DISTINCT( EXCEPT( vTableB, vTableA ))
RETURN
IF( 'Date Table'[EOMLogic] = "EOM",
COUNTROWS( vTable )
)
Which then looks something like this in your Date table.
With that in place created this measure pattern for Rolling months
rolling 12 months’ EOM sales =
VAR curEOM = MAX( 'Date Table'[EOM ID] )
VAR prevEOM =
SELECTCOLUMNS(
ADDCOLUMNS( VALUES( 'Date Table'[EOM ID] ),
"@PrevID", CALCULATE( MAX( 'Date Table'[EOM ID] ),
FILTER( ALL( 'Date Table' ),
'Date Table'[EOM ID] = EARLIER( 'Date Table'[EOM ID] )-11
)
)
), "IDs", [@PrevID]
)
VAR firstEOM = MINX( prevEOM, [IDs] )
VAR Result =
SWITCH( TRUE(),
firstEOM <0 || firstEOM = BLANK(), BLANK(),
SUMX(
FILTER( ALL( 'Date Table' ),
'Date Table'[EOM ID] IN GENERATESERIES( firstEOM, curEOM, 1 )
), [TotalSales]
)
)
RETURN
Result
With this result, also notice the correct placement of June - FY 2019 when the [EOM ID] is added.
Here’s your sample file: eDDNA - Custom EOM logic with Rolling months.pbix (1.4 MB)
and updated check. Corr prev 12 and 2 months.xlsx (15.9 KB)
Note that if you need further assistance correcting the error in the Date table, to create a new topic.
I hope this is helpful.