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
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
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.