Forum Discussion

pmay's avatar
pmay
Resolver I
4 years ago
Solved

Values aggregate incorrectly with legend

This may be a bug or a feature-change, but maybe there's a way around it in DAX and I'm hoping you can help me.   I have a measure which is as follows: % Var (Adjusted EBITDA) = VAR _AdjustedEB...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi pmay  , I would consider using the following formula instead of the above.

    % Var (Adjusted EBITDA) =
    VAR _Actual = [Adjusted EBITDA Actual]
    VAR _Budget = [Adjusted EBITDA Budget]
    VAR _AdjustedEBITDA =
        DIVIDE ( _Actual - _Budget, _Budget , 0 )
    RETURN
        _AdjustedEBITDA

    The problem that you are going to run into that Context Transition between Level 1 and Level 2 will not work as you desire.  This is why Power BI is adding the -100% to show -300% in the Stack Column Chart. 

    Note I wondering if this is the best visual to use.  Perhaps a waterfall chart would be better.  The reason I say this is because you can start with Budget on the Left equal 100% then show how the individual level 2 items contribute to the Actual to Budget column of 32.5% on the left.  It appears that you have 3 items at level 2, so 1 of these could be positive and the other 2 negative (e.g. +50%, -75%, -7.5% make up -32.5%)

    The adjusted formula could look like the following:

    % Var (Adjusted EBITDA) =
    VAR _Scope = ISINSCOPE( Level2) //True or False
    VAR _ActualFiltered = [Adjusted EBITDA Actual]
    VAR _BudgetFiltered = [Adjusted EBITDA Budget]
    VAR _ActualUnfitered = CALCULATE ( [Adjusted EBITDA Actual] , ALL( Level1 ) )
    VAR _ActualUnfitered = CALCULATE ( [Adjusted EBITDA Actual] , ALL( Level1 ) )
    VAR _Result =
        IF ( _Scope , 
           DIVIDE ( _ActualFiltered - _BudgetFiltered, _BudgetUnfiltered , 0 )
           DIVIDE ( _ActualUnfiltered - _BudgetUnfiltered, _BudgetUnfiltered , 0 )
        )
    RETURN
        _Result