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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
RRM_1977
Regular Visitor

Closing forecast (Real + Forecast) between dates with empty dates

Hello everyone,

I am not able to get the result that I need in relation to a sales closing forecast for this year.

Let me explain:

1. On the one hand I have a measure with real sales ([CY Sales])
2. On the other hand I have a measure with the sales forecast ([Sales Forecast]), which is exactly the value of sales on the same day of the previous year to simplify (CALCULATE ([CY Sales]; SAMEPERIODLASTYEAR (Dim_Calendar [Date ]))
3. The model has a dimension of dates (Dim_Calendar)
4. There are days of the year 2019 that do not have sales (for example on weekends)
5. The problem arises when I want to join both measures, that is, I want to validate the date of the last sale (in the Fact_Table), and assume the values ​​of current year [CY Sales] if it is less than or equal to that day, and the forecast values ​​([Sales Forecast]) if it is higher. As there are empty 2019 dates, I am not able to solve that problem.
6. In attached, the problem for a small interval. on days 16, 17 and 24 they should not appear in the last column (Real + Prevision)

Thanks in advance!!

Roberto

 

Screenshot.jpg

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

Use

 

CALCULATE ([CY Sales]; SAMEPERIODLASTYEAR (Fact[Date ]))

As, there no sales date, in fact, it will not give you data.

 

Check my example on last day

 

PriorDay Sales = CALCULATE(SUM(Sales[Sales_amount]),PREVIOUSDAY(Curr_Date[Sales_date]))
PriorDay Sales when day = CALCULATE(SUM(Sales[Sales_amount]),PREVIOUSDAY(Sales[Sales_date]))

 

 

Second will have data only when the current day has sales. There some missing sales date in data.

Screenshot 2019-09-14 14.31.32.png

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

RRM_1977
Regular Visitor

Thank you so much for the answers.

 

I've worked on the problem and I solved the situation including a new column on the Dim_Calendar table (

Anterior a ultimo registro de venta = Dim_Calendario[Date] <= MAX( Fact_Facturacion[Fecha] ) which compares each Di_Calendar[Date] with the reference (dynamic) on the Fact table (where the last date with sales information is).

 

So, the measure with the correct forecast is:

Ventas CY EST LE = SUMX( Dim_Calendario ; IF( ISBLANK( [Ventas CY] ) ; CALCULATE( [Ventas Prevision] ; Dim_Calendario[Anterior a ultimo registro de venta] = False ) ; BLANK() ))
 
Then, one of the LE (LE01) is: 
 
I hope that can help another people with the same problem.
 
Regards!
 
SharedScreenshot.jpg

View solution in original post

3 REPLIES 3
RRM_1977
Regular Visitor

Thank you so much for the answers.

 

I've worked on the problem and I solved the situation including a new column on the Dim_Calendar table (

Anterior a ultimo registro de venta = Dim_Calendario[Date] <= MAX( Fact_Facturacion[Fecha] ) which compares each Di_Calendar[Date] with the reference (dynamic) on the Fact table (where the last date with sales information is).

 

So, the measure with the correct forecast is:

Ventas CY EST LE = SUMX( Dim_Calendario ; IF( ISBLANK( [Ventas CY] ) ; CALCULATE( [Ventas Prevision] ; Dim_Calendario[Anterior a ultimo registro de venta] = False ) ; BLANK() ))
 
Then, one of the LE (LE01) is: 
 
I hope that can help another people with the same problem.
 
Regards!
 
SharedScreenshot.jpg
Ashish_Mathur
Super User
Super User

Hi,

I'm not clear with your question.  What exact result are you expecting?


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

Use

 

CALCULATE ([CY Sales]; SAMEPERIODLASTYEAR (Fact[Date ]))

As, there no sales date, in fact, it will not give you data.

 

Check my example on last day

 

PriorDay Sales = CALCULATE(SUM(Sales[Sales_amount]),PREVIOUSDAY(Curr_Date[Sales_date]))
PriorDay Sales when day = CALCULATE(SUM(Sales[Sales_amount]),PREVIOUSDAY(Sales[Sales_date]))

 

 

Second will have data only when the current day has sales. There some missing sales date in data.

Screenshot 2019-09-14 14.31.32.png

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.