Forum Discussion

mokhan's avatar
mokhan
Frequent Visitor
5 years ago
Solved

Comparison of previous years average with current months average in the bar graph

Hello All, I am a beginner with Power BI.   I have a column with date and another column with values. I would like to generate a bar graph beginning with previous years average bar follwed by curr...
  • v-yingjl's avatar
    5 years ago

    Hi mokhan ,

    Based on your description, you can create a calulated column like this to use it as X-axis:

    Axis = 
    IF (
        YEAR ( 'Table'[Date] ) = YEAR ( TODAY () ),
        'Table'[Date].[Month],
        CONVERT ( YEAR ( 'Table'[Date] ), STRING )
    )

    Then create these to measures, one of them calculates average about each year and each month for current year, another one calulates average about all years as a target:

    Avg = AVERAGE('Table'[Values])
    Avg_allyears = 
    CALCULATE ( AVERAGE ( 'Table'[Values] ), ALL ( 'Table' ) )

    Use a 'Line and stacked column chart ' to show it:

    Attached a sample file in the below, hopes to help you.

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.