cancel
Showing results 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

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

1 ACCEPTED SOLUTION
Super User

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

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

3 REPLIES 3
Super User

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

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

Helper IV

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

BEFORE:

AFTER:

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

Super User

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

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

Announcements

Power BI Monthly Update - July 2024

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

Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors