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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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