Obtaining data for different data periods

@JoaoMonteiro As Brian has suggested here disconnected table is the way to go, and here is another way to do it.

image

Measure = 
VAR CurrentMaxYear =
    CALCULATE ( MAX ( DisDates[Calendar Year Number] ), ALLSELECTED ( DisDates ) )
VAR PrevYear =
    CALCULATE (
        MAX ( DisDates[Calendar Year Number] ),
        DisDates[Calendar Year Number] < CurrentMaxYear,
        REMOVEFILTERS ( DisDates )
    )
VAR CurrentMonth =
    MONTH ( TODAY () ) --Replace with your own criteria of calculating month
VAR PrevYearJanFeb =
    CALCULATETABLE (
        VALUES ( DisDates[Calendar Year Month Number] ),
        DisDates[Month] IN { "January", "February" },
        DisDates[Calendar Year Number] = PrevYear,
        REMOVEFILTERS ( DisDates )
    )
VAR ThisYearCurrentMonth =
    CALCULATETABLE (
        VALUES ( DisDates[Calendar Year Month Number] ),
        DisDates[Month Number] = CurrentMonth,
        DisDates[Calendar Year Number] = CurrentMaxYear,
        REMOVEFILTERS ( DisDates )
    )
VAR OneList =
    UNION ( PrevYearJanFeb, ThisYearCurrentMonth )
VAR Result =
    CALCULATE (
        [Total Sales],
        TREATAS ( OneList, Dates[Calendar Year Month Number] )
    )
RETURN
    Result 

1 Like