Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.