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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
bh98381
Regular Visitor

Remove Forecast Data From Historical Dates

Here's a DAX pattern that I have used in the past to forecast revenue.  It worked great but now I'm trying to use the pattern on a different data set where there is not revenue for each day. 

 

Here's the DAX

 

$ Revenue Forecast = 
IF( 
    ISBLANK([$ Revenue]),
CALCULATE([$ Revenue 30D MA],
        SAMEPERIODLASTYEAR('Date'[Date])
         ),
BLANK())

On the other data set the ISBLANK function would remove the Forecast for historical dates.  But now since there are historical days without revenue the ISBLANK function is not working for the new data set.  

 

Here's an example below:

 

As you can see there was no revenue last year on 1/5 or 1/6 so because [$ Revenue] is blank now it calcuates a forecaste amount.

 

Any ideas?  Thanks!!!!

ISBLANK.PNG

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

@bh98381

Here's one idea:

$ Revenue Forecast =
VAR LastRevenueDate =
    LASTNONBLANK ( ALL ( 'Date'[Date] ), [$ Revenue] )
RETURN
    CALCULATE (
        CALCULATE ( [$ Revenue 30D MA], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ),
        KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], LastRevenueDate + 1, BLANK () ) )
    )

The logic is:

  1. Find the last date with nonblank actual revenue, and call that LastRevenueDate.
  2. For all dates after LastRevenueDate, calculate forecast revenue.

'Date' should be marked as date table for this to be a reliable measure (probably already is).

 

Does this work in your model?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

@bh98381

Here's one idea:

$ Revenue Forecast =
VAR LastRevenueDate =
    LASTNONBLANK ( ALL ( 'Date'[Date] ), [$ Revenue] )
RETURN
    CALCULATE (
        CALCULATE ( [$ Revenue 30D MA], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ),
        KEEPFILTERS ( DATESBETWEEN ( 'Date'[Date], LastRevenueDate + 1, BLANK () ) )
    )

The logic is:

  1. Find the last date with nonblank actual revenue, and call that LastRevenueDate.
  2. For all dates after LastRevenueDate, calculate forecast revenue.

'Date' should be marked as date table for this to be a reliable measure (probably already is).

 

Does this work in your model?

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Works Perfectly, Thanks Owen!!!

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.