Advanced Power BI Matrix Category Column Colors based on Date column

Advanced Power BI Matrix Category Column Colors based on Date column

Understanding Measure Color

Measure color in Power BI enables assigning distinct colors to different categories within a visualization. This feature proves particularly useful when dealing with categorical data, allowing users to quickly identify and distinguish between categories based on color coding.

Implementing Measure Color

To implement measure color in Power BI, follow these steps:

  1. Create a Measure: Begin by creating a measure that defines the color for each category. This measure can be based on existing fields or calculated values.

  2. Paste the DAX formula:

    WeekColors = 
    VAR SelectedDate = SELECTEDVALUE(FinalMerged[DayNumber])
    VAR DayNumber = VALUE(SelectedDate)
    VAR Hours = SELECTEDVALUE(FinalMerged[HoursLogged])
    RETURN
        SWITCH(
            DayNumber,
            1, "LightSkyBlue",
            2, "LightYellow",
            3, "LightGreen",
            4, "LightSalmon",
            5, "LightCoral",
            6, "Lavender",
            7, "Lightblue",
            8, "LightPink",
            9, "BurlyWood",
            10, "LightGray",
            11, "LightCyan",
            12, "LightPink",
            13, "LimeGreen",
            14, "LightSeaGreen",
            15, "PeachPuff",
            16, "LightSlateGray",
            17, "LightSteelBlue",
            18, "MistyRose",
            19, "Aquamarine",
            20, "LightSlateGray",
            21, "GoldenRod", // Replaced "DarkOrange" with "GoldenRod"
            22, "SandyBrown",
            23, "Thistle",
            24, "PowderBlue",
            25, "LavenderBlush",
            26, "LightSalmon",
            27, "LightCyan",
            28, "LightGreen",
            29, "LightGoldenrodYellow",
            30, "Plum",
            31, "Tomato", // Replaced "LightCrimson" with "Tomato"
            "Gold" // Default color for unmatched dates
        )
    

3. Apply Measure Color: Once the measure is created, navigate to the visualization where you want to apply measure color. Select the visualization and locate the "Format" pane.

4. Define Color Rules: In the conditional formatting dialog, select the measure created in step 1 as the "Based on field" option. Then, define color rules for each category using the "Rules" section.

5. Apply Rules and Enhance Visualization: Once the color rules are defined, click "OK" to apply the measure color to the visualization. The visualization will now display distinct colors for each category, enhancing data interpretation.