Forum Discussion

Vladimir_P's avatar
Vladimir_P
New Member
5 years ago
Solved

SAMEPERIODLASTYEAR() function comparison

Dear Community,  I would like to compare sales results in the same period of two consecutive years by using the SAMEPERIODLASTYEAR() function. When I do that, the presented result is not what I expe...
  • nandic's avatar
    5 years ago

    Hi Vladimir_P ,

    You might try this formula:

    PY amount =
    VAR _year =
        MAX ( Date[Year] )
    VAR _year_month =
        SELECTCOLUMNS (
            FILTER (
                SUMMARIZE ( Fact, Fact[Month], Fact[Year] ),
                Fact[Year] = _year 
            ),
            "YM", Fact[Month]
        )
    RETURN
        CALCULATE (

            SUM(Fact[Amount])SAMEPERIODLASTYEAR ( Date[Date] ), _year_month )


    If it doesn't work could you please share screenshot of your model and DAX that you used?
    This formula is based on 1 Fact table and 1 date table.

    Cheers,
    Nemanja Andic