Forum Discussion

cookm01's avatar
cookm01
Regular Visitor
1 year ago
Solved

Creating two straight average lines on a bar chart

Hello,   I am currently trying to create two straight average lines for a bar chart, to represent the averages for two years on the chart.   The context (using dummy data): I have a bar chart whi...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi cookm01 ,

    I create a table as you mentioned.

    Then I create a measure and here is the DAX code.

    Measure = 
    VAR _currentYear =
        MAX ( 'Table'[Year ] )
    RETURN
        CALCULATE (
            AVERAGE ( 'Table'[% of income ] ),
            FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Year ] = _currentYear )
        )

    Finally you will see what you want.

     

     

    Best Regards

    Yilong Zhou

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.