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
Anonymous
Not applicable

Color chart not repeating itself

Hi All 🙂
I need to make a plot where I have 150 different cities as my legend. The issue is now that the color chart is not repeating itself and just chooses random colors. How can I make it such that I have 8 colors repeating themselves up to all 150. So in case I choose City number 2 and 102 they are both within the same selection of colors.
Color chartColor chart
GraphGraph

This is what I get when I choose 2 different cities and this is NOT what I want, since they are not within the chosen color chart.
Skærmbillede 2022-04-01 101546.pngThanks in advance

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about something like so?

Color = 
SWITCH (
    TRUE (),
    MAX ( 'Table'[Category] ) IN { "A", "D", "G" }, "Red",
    MAX ( 'Table'[Category] ) IN { "B", "E", "H" }, "Yellow",
    MAX ( 'Table'[Category] ) IN { "C", "F" }, "Blue"
)

Icey_0-1649136502691.png

legend.gif

 

For more details, please check the attached .pbix file.

 

 

 

Best Regards,

Icey

 

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

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @Anonymous ,

 

How about something like so?

Color = 
SWITCH (
    TRUE (),
    MAX ( 'Table'[Category] ) IN { "A", "D", "G" }, "Red",
    MAX ( 'Table'[Category] ) IN { "B", "E", "H" }, "Yellow",
    MAX ( 'Table'[Category] ) IN { "C", "F" }, "Blue"
)

Icey_0-1649136502691.png

legend.gif

 

For more details, please check the attached .pbix file.

 

 

 

Best Regards,

Icey

 

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

MFelix
Super User
Super User

Hi @Anonymous ,

 

When you add a legend to your chart you can only select the colours manually so for this you would need to go city by city and select the colours.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Anonymous
Not applicable

Thank you for your answer 🙂
Is there any way I can avoid doing it manually?
What if I have 500 cities next time? That would very tedious...

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.

Top Solution Authors