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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jaryszek
Memorable Member
Memorable Member

Conditional coloring by rank not applying to time-series chart

 

Hi everyone,

my model looks like:

jaryszek_0-1761648872914.png

 

I’m using the following measures to color visuals dynamically based on ranking:

 

Rank (Current Axis) =
VAR Result =
    IF (
        ISINSCOPE ( fct_amortizedcosts[MeterSubCategory] ),
            RANKX (
                ALLSELECTED ( fct_amortizedcosts[MeterSubCategory] ),
                CALCULATE ( [Total Amortized Cost] ),
                ,
                DESC,
                DENSE
            ),
        IF (
            ISINSCOPE ( fct_amortizedcosts[MeterCategory] ),
            RANKX (
                ALLSELECTED ( fct_amortizedcosts[MeterCategory] ),
                CALCULATE ( [Total Amortized Cost] ),
                ,
                DESC,
                DENSE
            ),
            BLANK ()
        )
    )
RETURN Result

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"
)
 

This works perfectly in donut and bar charts, but when I try to apply the same color logic to a Line and clustered column chart (with Date on the X-axis), all columns turn gray:

jaryszek_0-1761648987431.png

 



Has anyone managed to make field value–based coloring work on a time-series chart when the rank is calculated by category (MeterCategory) and not by the date axis?

Example mode, use Problem to solve page:
https://drive.google.com/file/d/14lpEWK-MQ6JMU5_15WVh8Gv22AiGvdpR/view?usp=drive_link

I think that MeterCategory column does not exist in specific visual and this is why visual does not read it as ISINSCOPE function. 
I tried with HasONeValue but the same i think it is in visual level, not page level filter context...how to pass this ?

 

Thanks for any suggestions!

4 REPLIES 4
Kedar_Pande
Super User
Super User

Create a separate measure that preserves the category context:

 

Time Series Color =
VAR CurrentCategory = SELECTEDVALUE(fct_amortizedcosts[MeterCategory])
RETURN
IF(
NOT ISBLANK(CurrentCategory),
[Color by Rank],
"#B3B3B3"
)

 

Use this measure for conditional formatting in your time-series chart. It maintains the category context that gets lost in the date grouping.

 

Thank you. It is closer to finishing it, but it still is not working.

In chart I put:

jaryszek_0-1761660460839.png


but still within Color by Rank I am refering to 

VAR r = [Rank (Current Axis)]

 

which is using IsInScope: 

jaryszek_1-1761660500610.png


Best,
Jacek

FarhanJeelani
Super User
Super User

Hi @jaryszek ,

do you want something like below screenshot?

FarhanJeelani_0-1761653726738.png

 

Nope, this can be achieved by adding MeterCategory to the Legend. It is native Power BI behavior which sucks badly because I can not set up column colors through conditional formatting. 


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.