Forum Discussion

SSteven's avatar
SSteven
New Member
1 year ago
Solved

How to Maintain Consistent Segment Colors Across a Hierarchy Visual

Hi,    I've been struggling with maintaining consistent colors for segments in my Power BI hierarchical visualizations, particularly when dealing with different months of data. Here's my specific i...
  • SSteven's avatar
    1 year ago

    Resolved it. 
    Was in a tunnel vision, just had to eat. 

    This is the measure solution to use in the Conditionnal Formatting (in the Column section):  

    Segment_Color = 
    SWITCH(
        TRUE(),
        // No Purchase Categories
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "No Purchase, New Customers", "#D2B48C",  // Tan color
        
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "No Purchase, Prospects", "#B5C2CD",  // Dark Grey color
    
        // Active Categories
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Active, First Timers", "#D4C4C8",  // Mauve/pink
    
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Active, Repeat", "#B8BDB5",  // Lavender
    
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Active, Loyal", "#B8C7B5",  // Sage green
    
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Active, VIP", "#D2B48C",  // Tan color
    
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Active, At Risk", "#6A5D8D",  // Purple
    
        // Inactive Categories
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Inactive, Inactive", "#D9D9D9",  // Light grey
    
        SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & 
        SELECTEDVALUE('dataset'[segment2]) & ", " & 
        SELECTEDVALUE('dataset'[Segment]) = SELECTEDVALUE('DimDate'[Financial Year Month Proper]) & ", " & "Inactive, Lapsed", "#E6E6E6",  // Lighter grey
    
        "#CCCCCC" // Default color if none of the above conditions are met
    )