This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi,
I'm having some troubles with my SAMEPERIODLASTYEAR calculations.
I'm trying to compare the first 3 days of March '26 against the same period for last year using SAMEPERIODLASTYEAR, but what I get is the total amount of March '25.
The formula I'm using is:
Sales Y-1 = CALCULATE(
Solved! Go to Solution.
HI ,
According to the DAX page, SAMEPERIODLASTYEAR function (DAX) - DAX | Microsoft Learn for Sameperiodlastyear, "For calendar inpu...
Proud to be a Datanaut!
Private message me for consulting or training needs.
Dears,
thank you all for your answer!
they made me realize that the mismatch was between the last day of Calendar Table (set using TODAY() ) and the last SalesDate available (today too since the report is daily refreshed). To me, adding one day to the calendar (TODAY()+1) did the trick, but I believe the DATEADD solutions is cleaner.
For explanation purposes, the filter I was using had day granularity
Hi @TT_newbie
That is the expected behaviour of SAMEPERIODLASTYEAR - it returns the whole year unless you add the day of month as a filter.
Value SPLY 2 =
VAR LatestDateWithValue =
CALCULATE (
LASTNONBLANK ( Dates[Date], [Sum of Value] ),
ALLSELECTED ( Dates[Date] )
) -- or TODAY()
VAR _MMDD =
FORMAT ( LatestDateWithValue, "MMDD" )
RETURN
CALCULATE (
[Sum of Value],
SAMEPERIODLASTYEAR ( Dates[Date] ),
KEEPFILTERS ( FORMAT ( Dates[Date], "MMDD" ) <= _MMDD )
)
Please see the attached pbix.
Hi,
Your formula is correct. Do one of the following:
@TT_newbie
Why you are getting full month instead of three days.
The issue is that your slicer is selecting the full month, so:
SAMEPERIODLASTYEAR shifts the full month.
To compare only first 3 days:
Use a date range slicer, add dates in there.
Proposed Solution:
Make sure your slicer filters exact dates (not full month).
Use this DAX formula instead of sameperiodlastyear, this is easy to debug.
Sales Y-1 =
CALCULATE (
SUM (SalesAnalysis [Sales Amount]),
DATEADD (Calendar [Date], -1, YEAR)
)
If this helps, ✓ Mark as Kudos | Mark as Solution| Help Others
HI ,
According to the DAX page, SAMEPERIODLASTYEAR function (DAX) - DAX | Microsoft Learn for Sameperiodlastyear, "For calendar inpu...
Proud to be a Datanaut!
Private message me for consulting or training needs.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 31 | |
| 23 | |
| 22 | |
| 20 | |
| 15 |
| User | Count |
|---|---|
| 64 | |
| 41 | |
| 27 | |
| 22 | |
| 20 |