Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Fusilier
Helper III
Helper III

SAMEPERIODLASTYEAR not working.

Hi,

Trying to create a DAX command using this function.

My data is as follows:

screenshot 1.jpgscreenshot 2.jpg

The Month column is formatted as Date.

If I take out the SAMEPERIODLASTYEAR element it returns the value for the current month OK. But as soon as I add in SAMEPERIODLASTYEAR it returns a blank field.

Can anybody see what I'm doing wrong here?

 

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

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:

FreemanZ_0-1683133794841.png

View solution in original post

2 REPLIES 2
Fusilier
Helper III
Helper III

Apologies, my fault. Solution 2 works like a dream!

 

THANK YOU!

FreemanZ
Super User
Super User

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:

FreemanZ_0-1683133794841.png

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.