Forum Discussion
LostInTheFlood
4 years agoFrequent Visitor
Calculate forecast based on increase and previous calculated month result
Hi smart people, I have issues with a calculations and need your help. I’m trying to do a “total + forecast” measure (in the picture called Total). Where I have actuals I will show the actual a...
- 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. 🙂
LostInTheFlood
4 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.
DataInsights
Super User
4 years ago