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
basrooz
Advocate I
Advocate I

Show correct totals in forecast

Hi,

I have a data model that automatically refreshes each morning with yesterdays data. I've created a measure that's returning a forecast based on the actuals and the data from recent years.

 

I now want to calculate the total forecast until end of this year. I've used the following simple DAX formula for that. If the date yesterday or earlier it should pick up the actuals, otherwise it should pick up the forecast.

 

 

IF ( 
    MIN ( 'Date'[Date] ) < ( TODAY() - 1) , 
    [# Actuals] , 
    [# Forecast] 
    )

 

 

 

As a result, this is my data for this year (the numbers are exaggurated to show what's going wrong):

 

2022 monthResultforecast or actual
Jan50actual
Feb50actual
Mar50actual
Apr50actual
May50actual
Jun50actual + forecast
Jul100forecast
Aug100forecast
Sep100forecast
Oct100forecast
Nov100forecast
Dec100forecast
Total300 

 

The problem lies in the total for the year: it is only showing the total of the actuals (300), and not the total of the actuals and the forecast combined (it should return 900).

How can i change my formula so that the totals always represent a combination of the total and the actuals?

 

Thanks!
Bas

 

 

1 ACCEPTED SOLUTION
ALLUREAN
Solution Sage
Solution Sage

Hi, @basrooz 

You can check my article and hope it will help you

https://allure-analytics.com/index.php/2022/06/11/combine-actuals-forecast-in-power-bi/

 

 




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




View solution in original post

7 REPLIES 7
ALLUREAN
Solution Sage
Solution Sage

Hi, @basrooz 

You can check my article and hope it will help you

https://allure-analytics.com/index.php/2022/06/11/combine-actuals-forecast-in-power-bi/

 

 




Did I answer your question? Mark my post as a solution!


https://allure-analytics.com/
https://www.youtube.com/channel/UCndD_QZVNB_JWYLEmP6KrpA
https://www.linkedin.com/company/77757292/

Proud to be a Super User!




That's the one, thank you very much @ALLUREAN !

SpartaBI
Community Champion
Community Champion

@basrooz you need somthing like:

 

SUMX(
	VALUES('Date Table'[Date]),
	IF ( 
	    MIN ( 'Date'[Date] ) < ( TODAY() - 1) , 
	    [# Actuals] , 
	    [# Forecast] 
    )
)

 

 


2022-05-19 17_30_22-Re_ Need help on DAX function with measure vs colu... - Microsoft Power BI Commu.png


Full-Logo11.png

SpartaBI_3-1652115470761.png   SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Showcase Report – Contoso By SpartaBI

Hi @SpartaBI ,

Thanks for the quick response, but this doesn't do the trick unfortunately. the forecast numbers are highly impacted and the total is still showing the total of the actuals, not of the actuals and the forecast.

 

SpartaBI
Community Champion
Community Champion

@basrooz amm..so I need to see the file in this case 🙂

@SpartaBI  I cannot share it unfortunately.

All I can add is that the problem is in calculating the total. In the formula it's saying that if the time is less than today, it should pick the actuals. If you look at the total, then the time frame is 2022.01.01 - 2022.12.31 . This time frame have days that are less than today, hence it's only calculating the total of the actuals for this.

So somehow the formula should say that it should perhaps split up the total between a before today and an after today timeframe, and add those two numbers up... I can't seem to think of a good solution to it...

SpartaBI
Community Champion
Community Champion

@basrooz ok, let's try this 🙂 Watch this video:
https://www.youtube.com/watch?v=DKgF-5QHY68
This is the best source for DAX 🙂
Let me know if it solved your issue.

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.