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
paliman
Frequent Visitor

Calculate full year forecast as Actuals + Forecast

Hello everyone

I need some help with an Actuals + Forecast issue

 

We have forecasts updated on a quarterly basis, so that in March we plan for the period April to December. I need to calculate a full year forecast adding the Actuals for the previous months. Basically, I need the FY Forecast column:

 

 

 

 

I have tried
IF(ISBLANK([Forecast]),[Actual],[Forecast])
but as time goes and I have actual data, I found the following problem:

 

By Customer.PNG

1 ACCEPTED SOLUTION

HI @paliman,

You can use the following measure formulas to get the replaced total based on customer or product group:

FY Customer = 
VAR merge =
    ADDCOLUMNS (
        UNION (
            ADDCOLUMNS ( Actuals, "Source", "Actuals" ),
            ADDCOLUMNS ( Foreast, "Source", "Foreast" )
        ),
        "Month", LOOKUPVALUE ( 'Calendar'[Month], 'Calendar'[Date], [Date] )
    )
VAR summary =
    SUMMARIZE (
        merge,
        [Month],
        [Customer],
        "FY",
        VAR _fs =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Customer] = EARLIER ( [Customer] )
                        && [Source] = "Foreast"
                ),
                [Sales]
            )
        VAR _as =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Customer] = EARLIER ( [Customer] )
                        && [Source] = "Actuals"
                ),
                [Sales]
            )
        RETURN
            IF ( _fs = BLANK (), _as, _fs )
    )
RETURN
    IF (
        ISINSCOPE ( Customers[Customer Name] ),
        IF ( ISBLANK ( [Forecast Sales] ), [Actual Sales], [Forecast Sales] ),
        SUMX ( summary, [FY] )
    )

FY Product = 
VAR merge =
    ADDCOLUMNS (
        UNION (
            ADDCOLUMNS ( Actuals, "Source", "Actuals" ),
            ADDCOLUMNS ( Foreast, "Source", "Foreast" )
        ),
        "Month", LOOKUPVALUE ( 'Calendar'[Month], 'Calendar'[Date], [Date] )
    )
VAR summary =
    SUMMARIZE (
        merge,
        [Month],
        [Product],
        "FY",
        VAR _fs =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Product] = EARLIER ( [Product] )
                        && [Source] = "Foreast"
                ),
                [Sales]
            )
        VAR _as =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Product] = EARLIER ( [Product] )
                        && [Source] = "Actuals"
                ),
                [Sales]
            )
        RETURN
            IF ( _fs = BLANK (), _as, _fs )
    )
RETURN
    IF (
        ISINSCOPE ('Products'[Product description]),
        IF ( ISBLANK ( [Forecast Sales] ), [Actual Sales], [Forecast Sales] ),
        SUMX ( summary, [FY] )
    )

8.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
paliman
Frequent Visitor

Something went wrong and this picture was not posted, What I need is the FY Fcst Col. below:

 

FY Fcst.PNG

Hi @paliman,

Since I not so clear for your table data structure, can you please share some dummy data to test?

How to Get Your Question Answered Quickly 

In addition, you can take a look at the following blog to know how to handle blank values and use it with if statements:

Handling BLANK in DAX 
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Ok, sorry for the mess, I will try to explain it better.

 

I have two tables : Actuals and Forecasts; Forecast is updated on a quarterly basis.

 

I want to calculate the Full Year Forecast as follows:

For Q2 Forecast, which contains data for the period April to December, FY Forecast = Actuals Jan-Mar + Fcst Apr-Dec

 

I've tried the very simple approach of IF(ISBLANK([Forecast]),[Actuals],[Forecast]), but my problem is that if a particular product or customer was not forecasted, the result will be the actual value instead of a zero or a blank. Please see screenshot below. I have also posted a link to my Google Drive with the model I used for this example.

 

Thank you very much in advance

 

FY Fcst.PNGhttps://drive.google.com/file/d/1nasnWLt8eqmIgko9TimuOeLDPIcnUNDM/view?usp=sharing 

 

HI @paliman,

You can use the following measure formulas to get the replaced total based on customer or product group:

FY Customer = 
VAR merge =
    ADDCOLUMNS (
        UNION (
            ADDCOLUMNS ( Actuals, "Source", "Actuals" ),
            ADDCOLUMNS ( Foreast, "Source", "Foreast" )
        ),
        "Month", LOOKUPVALUE ( 'Calendar'[Month], 'Calendar'[Date], [Date] )
    )
VAR summary =
    SUMMARIZE (
        merge,
        [Month],
        [Customer],
        "FY",
        VAR _fs =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Customer] = EARLIER ( [Customer] )
                        && [Source] = "Foreast"
                ),
                [Sales]
            )
        VAR _as =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Customer] = EARLIER ( [Customer] )
                        && [Source] = "Actuals"
                ),
                [Sales]
            )
        RETURN
            IF ( _fs = BLANK (), _as, _fs )
    )
RETURN
    IF (
        ISINSCOPE ( Customers[Customer Name] ),
        IF ( ISBLANK ( [Forecast Sales] ), [Actual Sales], [Forecast Sales] ),
        SUMX ( summary, [FY] )
    )

FY Product = 
VAR merge =
    ADDCOLUMNS (
        UNION (
            ADDCOLUMNS ( Actuals, "Source", "Actuals" ),
            ADDCOLUMNS ( Foreast, "Source", "Foreast" )
        ),
        "Month", LOOKUPVALUE ( 'Calendar'[Month], 'Calendar'[Date], [Date] )
    )
VAR summary =
    SUMMARIZE (
        merge,
        [Month],
        [Product],
        "FY",
        VAR _fs =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Product] = EARLIER ( [Product] )
                        && [Source] = "Foreast"
                ),
                [Sales]
            )
        VAR _as =
            SUMX (
                FILTER (
                    merge,
                    [Month] = EARLIER ( [Month] )
                        && [Product] = EARLIER ( [Product] )
                        && [Source] = "Actuals"
                ),
                [Sales]
            )
        RETURN
            IF ( _fs = BLANK (), _as, _fs )
    )
RETURN
    IF (
        ISINSCOPE ('Products'[Product description]),
        IF ( ISBLANK ( [Forecast Sales] ), [Actual Sales], [Forecast Sales] ),
        SUMX ( summary, [FY] )
    )

8.png

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@paliman  Sorry, can you please explain further detail on your problem. What does the data model data look like? Your two screenshots are in very different formats, so which one is it that you're working with in Power BI, then we can use that to help you get the result you want.

 

I don't understand what the problem is highlighted in red- it does exactly what you've asked in the formula, so please explain further what you're trying to do so we can help more. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

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.