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
a__miller
Frequent Visitor

Calculate Rolling 3 Month Forecast

Hi, I would like to calculate the next 3 month's forecast, but I'm having trouble with the last month for each category.

 

Examples:

January 3 Month Future Rolling forecast = February Forecast+March Forecast+April Forecast

April 3 Month Future Rolling forecast = May Forecast+June Forecast

 

 

The value for June should be 0, but it is showing the total forecast, and I can't figure out why. What am I missing? Also, I'm not having any luck using DATESINPERIOD with this formula. 

 

3 Month Future Forecast = calculate(SUM('Table'[Forecast]),datesbetween(Table'[Month Reference],nextmonth('Table'[Month Reference]),dateadd('Table'[Month Reference],3,month)),filter('Table','Table'[Category]=earlier('Table'[Category])))

 

Based on the DAX above, this is what's being displayed

 

CategoryMonth ReferenceForecast3 Month Future Rolling Forecast
AJan-2250200
AFeb-2250250
AMar-2275325
AApr-2275250
AMay-22100150
AJun-22150500
BJan-22200500
BFeb-22200400
BMar-22200300
BApr-22100200
BMay-22100150
BJun-22100900
CJan-225001700
CFeb-225001900
CMar-226002000
CApr-226001400
CMay-22700150
CJun-227003600

 

This is what I'm looking for - the last month of each category should be 0.

 

CategoryMonth ReferenceForecast3 Month Future Rolling Forecast
AJan-2250200
AFeb-2250250
AMar-2275325
AApr-2275250
AMay-22100150
AJun-221500
BJan-22200500
BFeb-22200400
BMar-22200300
BApr-22100200
BMay-22100150
BJun-221000
CJan-225001700
CFeb-225001900
CMar-226002000
CApr-226001400
CMay-22700150
CJun-227000

 

 

 

1 ACCEPTED SOLUTION
a__miller
Frequent Visitor

Thanks for the responses. 

 

After correcting the relationship with the date table, this formula worked

 

(CALCULATE('Table'[Forecast],datesinperiod('Calendar'[Month],nextmonth(Calendar'[Month]),2,month)))

View solution in original post

5 REPLIES 5
a__miller
Frequent Visitor

Thanks for the responses. 

 

After correcting the relationship with the date table, this formula worked

 

(CALCULATE('Table'[Forecast],datesinperiod('Calendar'[Month],nextmonth(Calendar'[Month]),2,month)))
Ashish_Mathur
Super User
Super User

Hi,

You must have a Calendar Table with a relationship from the Date column of your Data Table to the Date column of the Calendar Table.  In the Calendar Table, write calculated column formulas for Year, Month name and Month number.  Sort the Month name by the Month number.  To your visual, drag Year and Month name from the Calendar Table.  Assuming Forecast is already a measure that you have written, write this measure

3 Month Future Rolling Forecast = calculate([forecast],datesbetween(calendar[date],min(calendar[date]),edate(max(calendar[date]),3)))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks so much for helping define the relationship better! I was able to correct the dax.

 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

NextThreeMonths = 
var cm = [Date]
return 0+CALCULATE(sum('Table'[Forecast]),ALLEXCEPT('Table','Table'[Category]),'Table'[Date]>cm,'Table'[Date]<EDATE(cm,4))

see attached.

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.