I am trying to forecast current month performance based on how far we are in the month. Goal is to establish how many cancellations will come in current month by inception. My DAX seems to be working fine when it comes to forecasting totals for items bought and cancelled in current month, but it doesn't want to forecast this month cancellation on product bought in previous months - it brings actuals up to date instead.
Any suggestions?
Here is my DAX:
Cancellations by inception =
VAR CurrentDate = [RefreshDate] -1
VAR CurrentMonth = MONTH(CurrentDate)
VAR CurrentYear = YEAR(CurrentDate)
VAR DaysElapsed = DAY(CurrentDate)
VAR TotalDaysInMonth = DAY(EOMONTH(CurrentDate, 0))
VAR RemainingDays = TotalDaysInMonth - DaysElapsed
-- Actual cancellations per month using the USERELATIONSHIP
VAR Actuals =
CALCULATE(sum
(fact_canc[Totals]),
USERELATIONSHIP(dimDate[Date], fact_canc[SaleDate]),
YEAR(dimDate[Date]) = YEAR(MAX(dimDate[Date])),
MONTH(dimDate[Date]) = MONTH(MAX(dimDate[Date]))
)
-- Current month cancellations up to today
VAR CurrentMonthActuals =
CALCULATE(
sum(fact_canc[Totals]),
USERELATIONSHIP(dimDate[Date], fact_canc[SaleDate]),
YEAR(dimDate[Date]) = CurrentYear,
MONTH(dimDate[Date]) = CurrentMonth,
fact_canc[SaleDate] <= CurrentDate
)
-- Forecasted total for the current month
VAR DailyRunRate = DIVIDE(CurrentMonthActuals, DaysElapsed, 0)
VAR ForecastedCurrentMonth = CurrentMonthActuals + (DailyRunRate * RemainingDays)
RETURN
IF(
YEAR(MAX(dimDate[Date])) = CurrentYear && MONTH(MAX(dimDate[Date])) = CurrentMonth,
ForecastedCurrentMonth,
Actuals
)+0
Tried to to change this part :
VAR CurrentMonthActuals =
CALCULATE(
sum(fact_canc[Totals]),
USERELATIONSHIP(dimDate[Date], fact_canc[SaleDate]),
YEAR(dimDate[Date]) = CurrentYear,
MONTH(dimDate[Date]) = CurrentMonth,
fact_canc[SaleDate] <= CurrentDate
)
as this is when I believe problem occurs