Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hello Guys,
I have a way of standarizing all colors on donuts charts using 2 measures:
-- Works at Category and Subcategory levels, blanks elsewhere
Rank (Current Axis) :=
VAR Result =
IF (
ISINSCOPE ( Dim_Meter[MeterSubCategory] ),
RANKX (
ALLSELECTED ( Dim_Meter[MeterSubCategory] ),
CALCULATE ( [Total Amortized Cost] ),
,
DESC,
DENSE
),
IF (
ISINSCOPE ( Dim_Meter[MeterCategory] ),
RANKX (
ALLSELECTED ( Dim_Meter[MeterCategory] ),
CALCULATE ( [Total Amortized Cost] ),
,
DESC,
DENSE
),
BLANK ()
)
)
RETURN Result
DAX
Color by Rank :=
VAR r = [Rank (Current Axis)]
RETURN
SWITCH (
TRUE(),
ISBLANK ( r ) || r > 5, "#B3B3B3",
r = 1, "#E81123",
r = 2, "#107C10",
r = 3, "#0078D4",
r = 4, "#FFB900",
r = 5, "#8E8CD8"
)
And this is working like a charm.
After implementing those 2 measures I change donut chart into bar chart, added color by rank measure and switched again to donut. Eveyrthing works great!
But what about line chart and conditional formatting like that?
How to create a proper SWITCH for it using DAX?
I am attaching example pbix:
https://drive.google.com/file/d/14lpEWK-MQ6JMU5_15WVh8Gv22AiGvdpR/view?usp=sharing
Best wishes,
Jacek
hi @jaryszek
Right now, conditional line color formatting in line charts is not supported in Power BI. There’s an idea for this that you can upvote : https://community.fabric.microsoft.com/t5/Fabric-Ideas/Conditionally-format-Line-in-Line-Chart/idi-p...
thank you very much,
no workaround with dax measure?
Best,
Jacek
To the best of my knowledge, no. However, you could try Power BI’s built-in Python support for this. Keep in mind that Python visuals have lots of limitations—for example, (they do not support tooltip hovering, etc.)
Below is a Python visual example I have created, and I’ve attached the PBIX file for your reference.
For this to work, you need to have Python installed on your machine: Python setup tutorial, or you can publish the PBIX file to the Power BI Service to view the visual.
Thank you.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.