Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

DAX Forecast Forward

I have found a DAX formula that forecasts deaths in US compared to actual deaths. Is there a way to get this to forecast forward (e.g. 2022) rather than overlapping?

 

Expected Deaths = 
var currentWeekNo = SELECTEDVALUE('Date'[WeekNo])
var currentYear = SELECTEDVALUE('Date'[Year])
var sameWeeksPriorTo2020 =

SUMMARIZE(
    FILTER(
        ALL('Date'),
        'Date'[WeekNo] = currentWeekNo && year('Date'[Date])<2020
    ),
    'Date'[WeekID]
)

var deathsinSameWeeksPriorTo2020 =
CALCULATETABLE(ADDCOLUMNS(sameWeeksPriorTo2020, "deaths", [Deaths]), ALL('Date'))
var minDeaths = MINX(deathsinSameWeeksPriorTo2020, [deaths])
var maxDeaths = MAXX(deathsinSameWeeksPriorTo2020, [deaths])
var rowCount = COUNTROWS(deathsinSameWeeksPriorTo2020)
var deathGrowth = DIVIDE(maxDeaths-minDeaths, rowCount-1)

return IF([Deaths]<>BLANK(),maxDeaths+(currentYear-2020+1)*deathGrowth)

 

3 Replies

  • Anonymous , Based on what I got

    Only after today, or taken max date from data

    //change return like

    return IF([Deaths]<>BLANK() && max('Date'[Date]) >=today() ,maxDeaths+(currentYear-2020+1)*deathGrowth)

    • Anonymous's avatar
      Anonymous
      Not applicable

      Yeah this works to get me up to today's data / expected data but I'm trying to push it forward on the X-axis into 2022. Perhaps a DATEADD(Date[Date])), +4,QUARTERS) or something like this?

  • V-lianl-msft's avatar
    V-lianl-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    I'm not sure about the context of your formula.To be sure, if you want to continue calculating the results for the next year, you need to iterate the deathGrowth results for 2021.

    If you are using a line chart, perhaps the built-in forecasting function can meet your needs.

    https://www.analyticsvidhya.com/blog/2020/07/time-series-forecasting-using-microsoft-power-bi/ 

     

    Best Regards,
    Liang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.