Forum Discussion

Fusilier's avatar
Fusilier
Icon for Helper III rankHelper III
3 years ago
Solved

SAMEPERIODLASTYEAR not working.

Hi, Trying to create a DAX command using this function. My data is as follows: The Month column is formatted as Date. If I take out the SAMEPERIODLASTYEAR element it returns the value f...
  • FreemanZ's avatar
    3 years ago

    hi Fusilier 

    try like:

    Prev Year = 
    CALCULATE(
        SUM(data[Incident]),
        FILTER(
            ALL(data),
            data[month]=EDATE(EARLIER(data[Month]), -12)
        ),
        ALLEXCEPT(data, data[Location])
    )

    or 

    Prev Year2 = 
    SUMX(
        FILTER(
            data,
            data[month]=EDATE(EARLIER(data[month]), -12)
                &&data[location]=EARLIER(data[location])
        ),
        data[Incident]
    )

     

    it worked like: