microsoft / powerbi-desktop-samples

Power BI Desktop sample files for the monthly release. Here you can find the PBIX files used in the monthly release videos.
MIT License
1.39k stars 843 forks source link

How to set conditional marker colors in line charts? #94

Open Yang-Shang opened 3 months ago

Yang-Shang commented 3 months ago

I'm learning the Power BI sample report - Regional Sales Sample. In the Win/Loss Ratio Overview page, there is a line chart "Closing Percentage by Month". In this line chart, the markers have different colors based on the Close%. When clicking somewhere else to narrow the dataset, the marker's color also changes accordingly. Can you give me some guidance on how to set conditional marker colors? Thank you!

line_chart_with_conditional_marker_color
mattantaliss commented 3 months ago

It's poor implementation from Microsoft, but the trick here is to first change that visual to a 'Clustered column chart'. Then, you can set the 'Color' of the 'Columns' (in the Visual settings) via the 'fx' icon. In there, you can specify a gradient, color by rules, or color by a field value. Once you have your colors set as desired, change the visual back to a 'Line chart'.

Here's an old (~5 years ago) YouTube video that shows off the idea: https://www.youtube.com/watch?v=A4iG8S4EpHs

Why it requires that clunky work-around (and why that work-around should even work in the first place) and is not a thing that is possible directly through the 'Line chart' settings is one of many Microsoft/Power BI decisions that is beyond me.