cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Niiru1
Helper V
Helper V

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)

 Forecast sample US.PNG

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Niiru1 ,

 

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.

 

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @Niiru1 ,

 

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.

 

amitchandak
Super User
Super User

@Niiru1 , 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)



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

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?

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors