Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
mokhan
Frequent Visitor

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 current months average bars. Something like below.

 

mokhan_0-1609927867809.png

How can I acheive this using Power BI. Any help would be appreciated!

 

Thankyou!

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

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:

re.png

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.

View solution in original post

2 REPLIES 2
v-yingjl
Community Support
Community Support

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:

re.png

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.

ToddChitt
Super User
Super User

@mokhan You asked this in the Power Query forum. This is probably better asked in the Desktop forum. But that won't stop people from trying to help you with your DAX

 

If I understand correctly, you would first need to get the MONTHLY SUM of your Metric, and from there, get the AVERAGE of those sums for the LAST YEAR. Is that correct?

 

Start with two calculated columns in your table: YEAR(Date) and MONTH(Date):

TheYear = YEAR([Date]) and TheMonth = MONTH([Date])

Then add a derived table in DAX:

Monthly Sums = SUMMARIZE ( <fact table name>, [TheYear], [TheMonth], "Sum of Metric", SUM( [Some column] ) )

Refer to this for SUMMARIZE: SUMMARIZE function (DAX) - DAX | Microsoft Docs

 

Finally, create a MEASURE as:

Average Monthly = AVG ( 'Montly Sums' [Sum of Metric] )

 

Hope this helps

 




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.