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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
James__
Helper I
Helper I

SIMPLE forecast Dax measure

Hi All,

 

Hoping  you can help as I'm exhausted looking at this one.

I have a targets report that has to include forecasting based on the day slicer (month/quarter/year).

They want the forecase to be sales_per_day * days_left_inmonth/quarter/year + sales_per_day

I can get sales per day: Divide(SUM)[sales],COUNTROWS(calendar)) BUT how do i work out how many days are left in the period?

 

Sorry i am sure this is fairly obvious - it has been a long day!

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @James__ 

 

Can you share some sample data and expected result in table format? To calculate how many days are left in the period, we need to know which date is the end date of a period and which date is the start date. If you select a month from the slicer, I guess probably you want to calculate the forecast result from the last sales date to the month end? If so, you can try a measure like below. 

left days =
VAR _lastSalesDate = CALCULATE ( MAX ( 'sales'[Date] ), ALL ( 'sales' ) )
RETURN
    DATEDIFF ( _lastSalesDate, MAX ( 'calendar'[Date] ), DAY )

 

This assumes that the last sales date is earlier than the period end date. If this is not what you want, please share some sample data or a sample pbix, this will help us understand your requirement better. How to provide sample data in the Power BI Forum

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @James__ 

 

Can you share some sample data and expected result in table format? To calculate how many days are left in the period, we need to know which date is the end date of a period and which date is the start date. If you select a month from the slicer, I guess probably you want to calculate the forecast result from the last sales date to the month end? If so, you can try a measure like below. 

left days =
VAR _lastSalesDate = CALCULATE ( MAX ( 'sales'[Date] ), ALL ( 'sales' ) )
RETURN
    DATEDIFF ( _lastSalesDate, MAX ( 'calendar'[Date] ), DAY )

 

This assumes that the last sales date is earlier than the period end date. If this is not what you want, please share some sample data or a sample pbix, this will help us understand your requirement better. How to provide sample data in the Power BI Forum

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it. Highly appreciate your Kudos!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.