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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jaryszek
Power Participant
Power Participant

Conditional formatting based on value, not a category name for line chart

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?

jaryszek_0-1760605349720.png


I am attaching example pbix:
https://drive.google.com/file/d/14lpEWK-MQ6JMU5_15WVh8Gv22AiGvdpR/view?usp=sharing

Best wishes,
Jacek

 






4 REPLIES 4
kushanNa
Super User
Super User

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. 

 

kushanNa_0-1760686668439.png

Thank you. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.