Forum Discussion
wrong % variation measure
hi powerbricco
Instead of using DATEADD, why not use SAMEPERIODLASTYEAR?
Note: Dates table must be marked as such.
3 Replies
- danextianSuper User
hi powerbricco
Instead of using DATEADD, why not use SAMEPERIODLASTYEAR?
Note: Dates table must be marked as such.
- bhanu_gautamSuper User
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]
)
) - MattiaFratelloSuper User
Hi powerbricco, have you tried to use SAMEPERIODLASTYEAR Dax Function? You may want to use MTD as well