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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
TWijnen90
New Member

SAMEPERIODLASTYEAR returns values from this year

Hi,

 

I'm using SAMEPERIODLASTYEAR to compare the number of incoming mails per month to the same month the previous year, but it appears to add the numbers from this year to last year.

 

The set-up is very simple: I have a table (Mail) which contains the number of mails (Amount), the type of mail (Category) and the date on which they came in (Date). Besides that I have a date table (tbl_date).

 

I have 2 formulas, Total This Year and Total Last Year:

CALCULATE([Totaal], tbl_date[Year] = YEAR(TODAY()))
and
CALCULATE([Totaal], SAMEPERIODLASTYEAR(tbl_date[Date]))
NB: [Totaal] is just the sum of the Amount.
 
For some reason, when I put these in a matrix, is takes the values from January and February this year, and adds them to last year.
Matrix Mail.PNG

January and February last year should just be empty, just like the remaining months for this year are. 

Now, we've only started to keep track of the number since May last year, that's why March and April are missing. And since it's only February this year, we've yet to complete a full year. Maybe that's where it goes wrong, I don't know. Any ideas?
1 ACCEPTED SOLUTION
amustafa
Solution Sage
Solution Sage

Adjust your DAX as...

 

CALCULATE(
    [Totaal], 
    SAMEPERIODLASTYEAR(tbl_date[Date]),
    tbl_date[Year] = YEAR(TODAY()) - 1
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
amustafa
Solution Sage
Solution Sage

Adjust your DAX as...

 

CALCULATE(
    [Totaal], 
    SAMEPERIODLASTYEAR(tbl_date[Date]),
    tbl_date[Year] = YEAR(TODAY()) - 1
)




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors