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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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

 

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

@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

 

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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