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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
steph_io
Advocate II
Advocate II

Dax to choose which measure to calculate based on Boolean field condition

I need to plot cumulative forecasted values - when I have these forecasted values available in my table

otherwise I take a 3Month running average of the actual values

 

Here are sample tables; 

Actual Costs   Forecasted Costs
ProductDateActual Product DateForecast
A2018-11-01 $  100.00 A2019-02-01 $  120.00
A2018-12-01 $  110.00 A2019-03-01 $  120.00
A2019-01-01 $  120.00 A2019-04-01 $  120.00
B2018-12-01 $  200.00 C2019-02-01 $  200.00
B2019-01-01 $  210.00 C2019-03-01 $  200.00
C2018-12-01 $  200.00 C2019-04-01 $  210.00
C2019-01-01 $  210.00   

 

 




I created a column in my Product table that tells me if a Product has forecasted values.  

Forecastexists = CONTAINS('Forecast','Forecast'[Product], Product[Product])
 
I need a formula that calculates cumulative sum when Forecastexists = true, else it's the cumulative Running 3M Average of Actuals....
so that it plots as a continuous line in the visual. 
2 ACCEPTED SOLUTIONS
v-frfei-msft
Community Support
Community Support

Hi @steph_io ,

 

One sample for your reference.

1. Create a date table and create relstionship between it and the actual table.

 

Table = CALENDARAUTO()

2. To create a calculated column as below.

 

Column = 
VAR _result =
    LOOKUPVALUE (
        'Forecasted Costs'[Forecast],
        'Forecasted Costs'[Date], DATEADD ( 'Table'[Date], 3, MONTH ),
        'Forecasted Costs'[Product ], 'Actual Costs'[Product]
    )
VAR _rows =
    CALCULATE (
        COUNTROWS ( 'Actual Costs' ),
        FILTER (
            'Actual Costs',
            'Actual Costs'[Date] <= EARLIER ( 'Actual Costs'[Date] )
                && 'Actual Costs'[Forecastexists] = FALSE ()
        )
    )
RETURN
    IF (
        ISBLANK ( _result ),
        CALCULATE (
            SUM ( 'Actual Costs'[Actual] ),
            FILTER (
                'Actual Costs',
                'Actual Costs'[Date] <= EARLIER ( 'Actual Costs'[Date] )
                    && 'Actual Costs'[Forecastexists] = FALSE ()
            )
        ) / _rows,
        _result
    )

Capture.PNG

 

Please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Hi @steph_io ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

2 REPLIES 2
v-frfei-msft
Community Support
Community Support

Hi @steph_io ,

 

One sample for your reference.

1. Create a date table and create relstionship between it and the actual table.

 

Table = CALENDARAUTO()

2. To create a calculated column as below.

 

Column = 
VAR _result =
    LOOKUPVALUE (
        'Forecasted Costs'[Forecast],
        'Forecasted Costs'[Date], DATEADD ( 'Table'[Date], 3, MONTH ),
        'Forecasted Costs'[Product ], 'Actual Costs'[Product]
    )
VAR _rows =
    CALCULATE (
        COUNTROWS ( 'Actual Costs' ),
        FILTER (
            'Actual Costs',
            'Actual Costs'[Date] <= EARLIER ( 'Actual Costs'[Date] )
                && 'Actual Costs'[Forecastexists] = FALSE ()
        )
    )
RETURN
    IF (
        ISBLANK ( _result ),
        CALCULATE (
            SUM ( 'Actual Costs'[Actual] ),
            FILTER (
                'Actual Costs',
                'Actual Costs'[Date] <= EARLIER ( 'Actual Costs'[Date] )
                    && 'Actual Costs'[Forecastexists] = FALSE ()
            )
        ) / _rows,
        _result
    )

Capture.PNG

 

Please check the pbix as attached.

 

Regards,

Frank

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Hi @steph_io ,

 

Does that make sense? If so, kindly mark my answer as the solution to close the case please. Thanks in advance.

 

Regards,
Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors