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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Spotto
Helper IV
Helper IV

Change the color of the previous year in a bar chart

hello everyone, I have a chart that I always compare a month and year with the previous one. I need to create a measure that changes the color of the previous year's bar.
Can anybody help me?
thanks

Spotto_0-1688670174595.png

 

1 ACCEPTED SOLUTION

Hi @Spotto 
Unfortunately, I cannot understand your test file...
From the attached image I understand that the line issue is not a visual issue, you just need to calculate it the right way.
Something like :

Average_Sales =
Var
currentSales = [sales_]
Var
Last_Sales = CALCULATE([sales_],PREVIOUSYEAR('financials'[Date]))
Return
(currentSales+Last_Sales)/2
Ritaf1983_0-1689040894238.png

Link to the sample file

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

View solution in original post

3 REPLIES 3
Ritaf1983
Super User
Super User

Hi @Spotto 
You just need to use a combo of line and clustered chart and put your year in a columns legend:

Ritaf1983_0-1688881816130.png

Ritaf1983_1-1688881862835.png

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

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

@Ritaf1983 tks for your help, but dont work. Only a part worked

BEFORE:

Spotto_0-1688992367452.png


AFTER:

Spotto_1-1688993145322.png

In this chart model that suggested the line does not show by month, but the total or the average only

is there a way to fix this?

I will leave the test file below for you
test.pbix 

Hi @Spotto 
Unfortunately, I cannot understand your test file...
From the attached image I understand that the line issue is not a visual issue, you just need to calculate it the right way.
Something like :

Average_Sales =
Var
currentSales = [sales_]
Var
Last_Sales = CALCULATE([sales_],PREVIOUSYEAR('financials'[Date]))
Return
(currentSales+Last_Sales)/2
Ritaf1983_0-1689040894238.png

Link to the sample file

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

 

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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