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
Anonymous
Not applicable

How to Calculate monthly forecast based on selected month view

I have two sets of values: actual sales for the month and a monthly forecast snapshot that has a new version every month.

How do you update a table that shows the forecast based on which dynamic forecast month version they’d like to see?

 

In Power BI I have 4 tables, a date table, a sales table, a forecast table, and a DF month selection table. The date table has a one to many relationship to both the sales and forecast table. The DF month selection table has no relationship to the other tables so that it doesn’t restrict which dates will appear from the date table.

 

I really struggle with replicating pretty straight forward excel calculations in Power BI.

Here’s the excel formula. I’m trying to calculate column D in Power BI.

 

Thanks for your help

test.png

1 ACCEPTED SOLUTION
Chas2002
Helper III
Helper III

Hi Luke,

 

The DAX would look something like:  IF([Selected DF Month]>=[Month Num], [Actual Sales]=[Forecast])

 

I haven't had a chance to test, but that would close to your existing excel formula.

 

Chas

 

View solution in original post

6 REPLIES 6
Chas2002
Helper III
Helper III

Hi Luke,

 

The DAX would look something like:  IF([Selected DF Month]>=[Month Num], [Actual Sales]=[Forecast])

 

I haven't had a chance to test, but that would close to your existing excel formula.

 

Chas

 

Anonymous
Not applicable

Thanks Chas.  This is what I initially tried.  However there's an odd quirck.

It works when I select the DF month to be between Jan-June.  However, once I get to July it starts pulling in the blank CY (current year actuals) values instead of the DF (see below).

 

I think the reason for this is it's looking at the average of the months in the table overall (which would be 6), so any months above 6 and below the select month pull CY.

 

I'm not sure how to get around this.

 

test.png

Hi Luke,

 

It would take a while to replicate the four tables and relationships.

 

Can you place your .pbix on dropbox or similar.  Santize the data.

 

Thanks,

Chas

Anonymous
Not applicable

Hi Chas,

It was a pretty massive report so after making a copy, stripping down the data, and resetting the tables to send to you as an example, it looks like it's no longer a problem and it calculates as I would expect.

 

Unforuntately, now I have to figure out why it is a problem in my existing report as I can't rebuild everything from scratch.

 

Thanks for your help

Just add an IF([CY] to check to see if CY existits and then perform an alternative calculation if it does not.  You dont need to say ISBLANK you can just say IF([Measure],then,else).  If you leave off the else term it will return NULL  measure if blank.  This is also a useful trick if you want to block a measure from calcualating for display purposes.. 

 

 

Anonymous
Not applicable

Hi Seward,

Please see my response here for why the if statement is causing an issue.

 

Thanks

 

https://community.powerbi.com/t5/Desktop/How-to-Calculate-monthly-forecast-based-on-selected-month-v...

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.