Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Solved! Go to Solution.
hi @powerbricco
Instead of using DATEADD, why not use SAMEPERIODLASTYEAR?
Note: Dates table must be marked as such.
Hi @powerbricco, have you tried to use SAMEPERIODLASTYEAR Dax Function? You may want to use MTD as well
hi @powerbricco
Instead of using DATEADD, why not use SAMEPERIODLASTYEAR?
Note: Dates table must be marked as such.
@powerbricco You need to adjust your measure to account for the number of days that have passed in the current month.
Create a measure to calculate the total sales up to the current day in the current month:
DAX
[IMP. RIGA TOT. YTD] =
CALCULATE(
[IMP. RIGA TOT.],
DATESBETWEEN(
CalendarTable[Date],
STARTOFMONTH(CalendarTable[Date]),
MAX(CalendarTable[Date])
)
)
Create a measure to calculate the total sales up to the same day in the previous year:
DAX
[Total Sales_PY_Sameday YTD] =
CALCULATE(
[IMP. RIGA TOT.],
DATESBETWEEN(
CalendarTable[Date],
SAMEPERIODLASTYEAR(STARTOFMONTH(CalendarTable[Date])),
SAMEPERIODLASTYEAR(MAX(CalendarTable[Date]))
)
)
Adjust your variation % measure to use these new measures:
DAX
[Total Sales_PY% PY] =
IF (
ISBLANK(DIVIDE(
([IMP. RIGA TOT. YTD] - [Total Sales_PY_Sameday YTD]),
[Total Sales_PY_Sameday YTD]
)),
0,
DIVIDE(
([IMP. RIGA TOT. YTD] - [Total Sales_PY_Sameday YTD]),
[Total Sales_PY_Sameday YTD]
)
)
Proud to be a Super User! |
|