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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
avachris
Frequent Visitor

Unable to use AddColumns Summarize with Calculated Dimension

I am working with both forecasts and actuals, and I would like to create a version which is called "Forecast + Actuals" which is a combination of actuals and the forecast values which is after the last date of actuals. 

 

I know you can do this via a measure like if selected value = "Forecast + Actuals" then return calculate measure, but I would prefer to do it in one measure to reduce the complexity of my measure tree.

 

Here is an example data set. 

 

DateVersionValue
31-OctForecast100
30-SepForecast150
30-SepActual120
31-AugActual100

 

Here is the Version Dimension table. "Forecast + Actuals" doesn't exist in my fact table, but can be derived from the fact table through a combination of Forecast and Actuals. 

 

Version Dimension Table
Forecast
Actuals
Forecast + Actuals

 

I would like a measure which would populate the following: 

Version8/319/3010/31
Forecast 150100
Actuals100120 
Forecast + Actuals100120100

 

I was trying to accomplish it like this via this measure: 

DataSum = 

 VAR MaxActualsDate =
    CALCULATE ( MAX ( FactTable[Date], Version = "Actuals" ) )
VAR SummaryData =
    ADDCOLUMNS (
        SUMMARIZE ( 'FactTable', 'Date'[Date], Versions[Version] ),
        // this is the core table
        "@SourceValue", CALCULATE ( SUM ( FactTable[Value] ) )
    )
RETURN
    IF (
        SELECTEDVALUE ( Versions[Version] ) = "Current Forecast + Actuals",
        CALCULATE ( SUMX ( SummaryData, [@SourceValue] ), [Version] = "Actuals" )
            + CALCULATE (
                SUMX ( SummaryData, [@SourceValue] ),
                [Version] = "Forecast",
                Date[Date] > MaxActualsDate
            ),
         SUMX ( SummaryData, [@SourceValue] )
    )

 

I didn't find any success here - so then I decided to modify the variable table by unioning the "Forecast + Actuals" into the SummaryData variable table. When i look at this in DAX studio, the table does have  "Forecast + Actuals" with values, however, I am unable to bring this into a visual.

 

DataSum = 

var MaxActualsDate = calculate( max(FactTable[Date],Version="Actuals")

Var SummaryData = ADDCOLUMNS (
    TREATAS (
        UNION (
            SUMMARIZE ( 'FactTable', 'Date'[Date], Versions[Version] ), // this is the core table
            ADDCOLUMNS (
                SUMMARIZE ( FactTable', 'Date'[Date], Versions[Version]  ),
                "Version", "Current Forecast + Actuals" // this is where i'm trying to add the "fake data series"
            )
        ),
        'Date'[Date],
        Versions[Version]
    ),
    "@SourceValue",
        IF (
            [Version] = "Current Forecast + Actuals",
            CALCULATE ( SUM ( FactTable[Value] ), ALL ( Versions ), Versions[Version] = "Actuals" ),
            CALCULATE ( SUM (FactTable[Value])
        )
)

 

Return Sumx ( SummaryData, [@SourceValue])

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @avachris 

Please try measure formula like:

Measure1 =
VAR _forecast =
    CALCULATE ( SUM ( FactTable[Value] ), FactTable[Version] = "Forecast" )
VAR _actual =
    CALCULATE ( SUM ( FactTable[Value] ), FactTable[Version] = "Actual" )
RETURN
    SWITCH (
        MAX ( 'Version'[Version] ),
        "Forecast", _forecast,
        "Actuals", _actual,
        IF ( ISBLANK ( _actual ), _forecast, _actual )
    )

veasonfmsft_0-1670320911794.png

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-easonf-msft
Community Support
Community Support

Hi, @avachris 

Please try measure formula like:

Measure1 =
VAR _forecast =
    CALCULATE ( SUM ( FactTable[Value] ), FactTable[Version] = "Forecast" )
VAR _actual =
    CALCULATE ( SUM ( FactTable[Value] ), FactTable[Version] = "Actual" )
RETURN
    SWITCH (
        MAX ( 'Version'[Version] ),
        "Forecast", _forecast,
        "Actuals", _actual,
        IF ( ISBLANK ( _actual ), _forecast, _actual )
    )

veasonfmsft_0-1670320911794.png

 

Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors