Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello,
I have 2 measures as follows:
CY Sales =
Var CY = MAX('Date table'[Year])
return CALCULATE(SUM(Transactions[SalesAmnt], 'Date table'[Year] = CY)
and
PY Sales = CALCULATE([CY Sales], SAMEPERIODLASTYEAR('Date table'[Date]))
but my PY returns the total sales for last year and not the sales for the same period as the current year.
What may be causing this?
Thanks,
Vlado
Solved! Go to Solution.
@Newby_TCO_123 Honestly, lots of things. I would recommend avoiding TI functions in DAX. I have some videos coming out in the next few weeks about these and how quirky they can be. This will help. To **bleep** With Time Intelligence - Microsoft Power BI Community. Specifically:
ToHellWithSAMEPERIODLASTYEAR =
VAR __NumIntervals = -1
VAR __MaxDate = MAXX('Calendar',[Date])
VAR __MinDate = MINX('Calendar',[Date])
VAR __Start = __MinDate
VAR __End =
SWITCH(TRUE(),
__NumIntervals = 0 || __NumIntervals > 0,__MaxDate,
IF(
MONTH(__MaxDate) = 2 && DAY(__MaxDate) > 28,
EOMONTH(__MaxDate,__NumIntervals*12),
DATE(YEAR(__MaxDate) + __NumIntervals, MONTH(__MaxDate), DAY(__MaxDate))
)
)
RETURN
FILTER('Calendar', [Date] >= __Start && [Date] <= __End)
@Newby_TCO_123 Honestly, lots of things. I would recommend avoiding TI functions in DAX. I have some videos coming out in the next few weeks about these and how quirky they can be. This will help. To **bleep** With Time Intelligence - Microsoft Power BI Community. Specifically:
ToHellWithSAMEPERIODLASTYEAR =
VAR __NumIntervals = -1
VAR __MaxDate = MAXX('Calendar',[Date])
VAR __MinDate = MINX('Calendar',[Date])
VAR __Start = __MinDate
VAR __End =
SWITCH(TRUE(),
__NumIntervals = 0 || __NumIntervals > 0,__MaxDate,
IF(
MONTH(__MaxDate) = 2 && DAY(__MaxDate) > 28,
EOMONTH(__MaxDate,__NumIntervals*12),
DATE(YEAR(__MaxDate) + __NumIntervals, MONTH(__MaxDate), DAY(__MaxDate))
)
)
RETURN
FILTER('Calendar', [Date] >= __Start && [Date] <= __End)
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 6 | |
| 6 | |
| 4 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 24 | |
| 17 | |
| 9 | |
| 7 | |
| 6 |