Forum Discussion
Calculate forecast based on increase and previous calculated month result
- 4 years ago
Try these measures. I made the Period column a date by adding the first day of the month (2022-01 becomes 2022-01-01). This will enable you to create a relationship with the date table. Alternatively, you could create a Period Number column with values like 202201, and use Period Number instead of Period in the Running Total measure.
Actual = SUM ( FactTable[Actual] )Forecast = SUM ( FactTable[Forecast] )Running Total = VAR vLastActual = CALCULATE ( LASTNONBLANKVALUE ( FactTable[Actual], [Actual] ), ALLSELECTED ( FactTable ) ) VAR vResult = IF ( MAX ( FactTable[Actual] ) <> BLANK (), [Actual], vLastActual + CALCULATE ( [Forecast], FILTER ( ALLSELECTED ( FactTable ), FactTable[Period] <= MAX ( FactTable[Period] ) ) ) ) RETURN vResult - 4 years ago
Try this measure. I adjusted the DAX to handle months where both Actual and Forecast exist.
Running Total = VAR vLastActual = CALCULATE ( LASTNONBLANKVALUE ( Actual[Actual Value], [ActualValue] ), ALLSELECTED ( Actual ) ) VAR vLastActualDate = CALCULATE ( LASTNONBLANK ( 'Date'[Date], [ActualValue] ), ALLSELECTED ( Actual ) ) VAR vResult = IF ( MAX ( Actual[Actual Value] ) <> BLANK (), [ActualValue], vLastActual + CALCULATE ( [ForecastValue], FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) && 'Date'[Date] > vLastActualDate ) ) ) RETURN vResultNow you can take that vacation. 🙂
Hi DataInsights
When I tried on my "real" file I got the last actual value as the 2022-11 value.
So I started to prepare a dummy file to upload (hope the link works) and then I acutally got the 2022-10 value in 2022-11. BUT the calculation took into account all previous forcast values where I have actuals.
I need a vacation 🙂
- DataInsights4 years ago
Super User
Try this measure. I adjusted the DAX to handle months where both Actual and Forecast exist.
Running Total = VAR vLastActual = CALCULATE ( LASTNONBLANKVALUE ( Actual[Actual Value], [ActualValue] ), ALLSELECTED ( Actual ) ) VAR vLastActualDate = CALCULATE ( LASTNONBLANK ( 'Date'[Date], [ActualValue] ), ALLSELECTED ( Actual ) ) VAR vResult = IF ( MAX ( Actual[Actual Value] ) <> BLANK (), [ActualValue], vLastActual + CALCULATE ( [ForecastValue], FILTER ( ALLSELECTED ( 'Date' ), 'Date'[Date] <= MAX ( 'Date'[Date] ) && 'Date'[Date] > vLastActualDate ) ) ) RETURN vResultNow you can take that vacation. 🙂
- LostInTheFlood4 years agoFrequent Visitor
DataInsights What can I say but thank you!
Thank you so much for thaking the time. This was exactly what I needed.- DataInsights4 years ago
Super User