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.
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)
Solved! Go to Solution.
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.
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.
@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?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
81 | |
66 | |
58 |
User | Count |
---|---|
150 | |
119 | |
104 | |
87 | |
67 |