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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Dshami
Frequent Visitor

Issue with Forecast DAX measure

I have a scenario to show the Expenses data for selected year and unselected months( if month selected as January, It should show Expenses of February to December for selected year, for multiple selections same functioning).

I have created two dax as below

 

1. End Date = MAX(Calendar [Date])

( Max calendar date is last day of current year)

 

2. Exp Forecast = CALCULATE ( SUM( Table [Sales]), DATESBETWEEN(Calendar [Date], DATE(YEAR([End Date]), MONTH ([End Date])+1,01), DATE(YEAR([End Date]),12,31)))

 

But the catch is with this second measure with no month selection and only year selection it gives me blank values. If no month selection I need the Expense to be shown for all months. 

What changes are supposed to be done?

 

Would really appreciate help on this..

Thanks in advance!

 

 

 

 

 

1 ACCEPTED SOLUTION
MAwwad
Solution Sage
Solution Sage

The reason you are seeing blank values with the Exp Forecast measure when no month is selected is because the DATESBETWEEN function is not receiving any dates to filter by. To show expenses for all months in the selected year when no month is selected, you can modify the Exp Forecast measure as follows:

Exp Forecast = IF(ISFILTERED(Calendar[Month]), CALCULATE(SUM(Table[Sales]), DATESBETWEEN(Calendar[Date], DATE(YEAR([End Date]), MONTH([End Date])+1, 1), DATE(YEAR([End Date]), 12, 31)) ), CALCULATE(SUM(Table[Sales]), DATESBETWEEN(Calendar[Date], DATE(YEAR([End Date]), 1, 1), DATE(YEAR([End Date]), 12, 31)) ) )

This measure uses the ISFILTERED function to check if the Month column is being filtered. If it is, then the original calculation using DATESBETWEEN is used. If it is not being filtered, then the calculation is modified to show expenses for all months in the selected year by changing the start date to January 1st of the selected year.

I hope this helps!

View solution in original post

1 REPLY 1
MAwwad
Solution Sage
Solution Sage

The reason you are seeing blank values with the Exp Forecast measure when no month is selected is because the DATESBETWEEN function is not receiving any dates to filter by. To show expenses for all months in the selected year when no month is selected, you can modify the Exp Forecast measure as follows:

Exp Forecast = IF(ISFILTERED(Calendar[Month]), CALCULATE(SUM(Table[Sales]), DATESBETWEEN(Calendar[Date], DATE(YEAR([End Date]), MONTH([End Date])+1, 1), DATE(YEAR([End Date]), 12, 31)) ), CALCULATE(SUM(Table[Sales]), DATESBETWEEN(Calendar[Date], DATE(YEAR([End Date]), 1, 1), DATE(YEAR([End Date]), 12, 31)) ) )

This measure uses the ISFILTERED function to check if the Month column is being filtered. If it is, then the original calculation using DATESBETWEEN is used. If it is not being filtered, then the calculation is modified to show expenses for all months in the selected year by changing the start date to January 1st of the selected year.

I hope this helps!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors