Forum Discussion

Danminar's avatar
Danminar
Frequent Visitor
3 years ago
Solved

Help with Dynamic Actual Amounts - Comparing 2 Forecast Plans

Hi,   I have a problem where I need to be able to compare 2 different "Plans" with YTD #s.   So the way these are set up, the naming convention is "[Year] [Month Number (Actuals)]+(12-[Month Numb...
  • DataInsights's avatar
    DataInsights
    3 years ago

    Danminar,

     

    Try creating a disconnected table for each plan (no relationships). You can do this in Power Query or DAX. Here are the calculated tables:

     

    CostPlan1 = DISTINCT ( FactTable[Cost Plan] )
    CostPlan2 = DISTINCT ( FactTable[Cost Plan] )

     

    Create a slicer for each of these tables (Plan 1, Plan 2).

     

    Measures:

     

    Plan 1 Amount YTD = 
    // get Actuals Thru for first plan and convert from text to date
    VAR vActualsThru =
        CALCULATE (
            DATEVALUE ( SELECTEDVALUE ( FactTable[Actuals Thru] ) ),
            TREATAS ( CostPlan1, FactTable[Cost Plan] )
        )
    VAR vDatesYTD =
        DATESBETWEEN (
            DimDate[Date],
            DATE ( YEAR ( vActualsThru ), 1, 1 ),
            vActualsThru
        )
    VAR vResult =
        CALCULATE (
            SUM ( FactTable[Amt] ),
            vDatesYTD,
            TREATAS ( CostPlan1, FactTable[Cost Plan] )
        )
    RETURN
        vResult
    Plan 2 Amount YTD = 
    // get Actuals Thru for first plan and convert from text to date
    VAR vActualsThru =
        CALCULATE (
            DATEVALUE ( SELECTEDVALUE ( FactTable[Actuals Thru] ) ),
            TREATAS ( CostPlan1, FactTable[Cost Plan] )
        )
    VAR vDatesYTD =
        DATESBETWEEN (
            DimDate[Date],
            DATE ( YEAR ( vActualsThru ), 1, 1 ),
            vActualsThru
        )
    VAR vResult =
        CALCULATE (
            SUM ( FactTable[Amt] ),
            vDatesYTD,
            TREATAS ( CostPlan2, FactTable[Cost Plan] )
        )
    RETURN
        vResult

     

    Sample data:

     

     

    Result: