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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Rai_Lomarques
Frequent Visitor

Bar chart with the last 12 months and the total average

Hello friends,
Can you tell me how I can achieve the same result as the graph in the image below? I need to create a graph in Power BI where on the X axis I have the last 12 months prior to the month that is being filtered in the data segmentation, the months need to be in the "MM/YYYY" format. On the same X axis I need to have a column for the AVERAGE of these last 12 months.

 

Rai_Lomarques_0-1742133884013.png

When the user filters the month "09/2024" in the segmentation, then the graph should show the last 12 months prior to "09/2024"

 

6 REPLIES 6
V-yubandi-msft
Community Support
Community Support

Hi @Rai_Lomarques ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

 

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @Rai_Lomarques ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you.

V-yubandi-msft
Community Support
Community Support

Hi @Rai_Lomarques ,

Has your issue been resolved, or do you require any further information? Your feedback is valuable to us. If the solution was effective, please mark it as 'Accepted Solution' to assist other community members experiencing the same issue.

Anonymous
Not applicable

Hi @Rai_Lomarques ,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or Accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information and description to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Deku
Community Champion
Community Champion

as mentioned by @lbendlin you could include a average line

 

Avg Amount = 
AVERAGEX(
    ALLSELECTED( 'dates'[Year Month] )
    ,[Amount]
)

 

Deku_1-1742158634802.png

 

If you really want that extra bar.

 

I created a date dimension

dates = 
ADDCOLUMNS(
    CALENDARAUTO()
    ,"Year", YEAR( [Date] )
    ,"Year Month", EOMONTH( [Date] ,0 )
    ,"Year Month No", (YEAR( [Date] ) * 100) + MONTH( [Date] )
    ,"Month", MONTH( [Date] )
)

and a table for the axis

xAxis = 
UNION(
    SELECTCOLUMNS(
        SUMMARIZE( 'dates', 'dates'[Year Month], dates[Year Month No] )
        ,"Index", dates[Year Month No]
        ,"Label", FORMAT( dates[Year Month], "mm/yyyy" )
        ,"Hex", "#0f3057"
    )
    ,ROW( "Index", 999999, "Lebel", "Average", "Hex", "#604e82" )
)

Added a mesure for the y axis

Amount With Avg = 
IF( 
    SELECTEDVALUE( xAxis[Label] ) = "Average" 
    ,[Avg Amount]
    ,CALCULATE(
        [Amount]
        ,TREATAS( VALUES( xAxis[Index] ) , dates[Year Month No] )
    )
)

and a measure for conditional formatting on the bars

Colour = SELECTEDVALUE( xAxis[Hex] )

Deku_2-1742158787326.png

 


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
lbendlin
Super User
Super User

Showing the same data twice in a visual is a design red flag. Consider using an average line instead of the column.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.