Forum Discussion

Nick2358's avatar
Nick2358
Icon for Helper III rankHelper III
5 years ago
Solved

Calculated measure using other calculated measure

Hello everyone,   I have this measure that calculates YTD Actual (-2 months) + Budget of months left.   When I use the following with "Calculate(SUM))" everything works perfectly:   Act + Bdgt...
  • DataInsights's avatar
    DataInsights
    5 years ago

    Nick2358,

     

    Try this. Each measure needs a CALCULATE. 

     

    Act + Bdgt_GP_Bef_Com =
    VAR _max1 =
        MAXX ( ALLSELECTED ( Dates ), Dates[Date_2] )
    VAR _max =
        EOMONTH ( DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 ), 0 )
    VAR _min =
        DATE ( YEAR ( _max1 ), 1, 1 )
    VAR _minb =
        DATE ( YEAR ( _max1 ), MONTH ( _max1 ) - 2, 1 )
    VAR _maxb =
        DATE ( YEAR ( _max1 ), 12, 31 )
    RETURN
        CALCULATE (
            [YTD_GP_Before_Com],
            FILTER ( Dates, Dates[Date_2] <= _max && Dates[Date_2] >= - _min )
        )
            + CALCULATE (
                [YTD_Bdgt_GP_Before_Com], FILTER(Dates, Dates[Date_2] <= _maxb
                    && Dates[Date_2] >= _minb
            )