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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mwalden
Frequent Visitor

Color Coding X-Axis by Year

I am working on a stacked column chart, where I want to customize the colors based on both the legend information and the x-axis information. Here is as far as I've come:

 

example.PNG

As you can see I have the x-axis split in 2022/2023 by Month, and in the legend I have "Nature of spending":

legend.PNG

 

 

What I would like to do, is have the colors be different for 2022 and 2023. It's not very obvious in the current layout, that it's two different columns per month. But I can only speficify the color based on the legend. 

 

Any ideas on how to do this? - Without having to pay for a custom visual developed by third party?

1 ACCEPTED SOLUTION
olgad
Resident Rockstar
Resident Rockstar

Hi, may be you can make 4 measures. Provided you always show the current and the previous year. 

Calls (2023)= Calculate(Count(Calls)), 'Date Table'[Year]=Year(Today()))
Calls (2022)= Calculate(Count(Calls)), 'Date Table'[Year]=Year(Today())-1)
 and the same for emails, then you will get something like this: 

olgad_0-1698270318362.png

 

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

View solution in original post

3 REPLIES 3
olgad
Resident Rockstar
Resident Rockstar

Hi, may be you can make 4 measures. Provided you always show the current and the previous year. 

Calls (2023)= Calculate(Count(Calls)), 'Date Table'[Year]=Year(Today()))
Calls (2022)= Calculate(Count(Calls)), 'Date Table'[Year]=Year(Today())-1)
 and the same for emails, then you will get something like this: 

olgad_0-1698270318362.png

 

 


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime
mwalden
Frequent Visitor

Do you put the measures in the Y-Axis? this is the error message I get for each of them

mwalden_0-1698324952328.png

 

Nevermind - I got it to work! thanks so much!!!!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.