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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
jcastr02
Post Prodigy
Post Prodigy

shading states dependent if have functions

I am trying to assign different colors for different states dependent if they have the functions or not (DE, DR, PCC are the functions).

 

Example - 1 color would be states AL, GA, HI, MS, NE (they have zero across the board)

Example 2 color would be DE, ME, MN (they only have zeros PCC)

Example 3 color would be KY (has zero in DE and PCC)

Example 4 color would be all the rest of the states (they have values in each of the functions)

Screenshot 2024-02-26 095219.png

1 ACCEPTED SOLUTION
v-kongfanf-msft
Community Support
Community Support

Hi @jcastr02 ,

 

Based on your description, it appears that you want to classify states into groups based on specific conditions and then apply unique color codes to those groups. Here is a step-by-step approach to accomplish this in Power BI:

 

StateCategory = 
VAR DE_Value =
    MAX ( 'Table'[DE_Column] )
VAR DR_Value =
    MAX ( 'Table'[DR_Column] )
VAR PCC_Value =
    MAX ( 'Table'[PCC_Column] )
RETURN
    SWITCH (
        TRUE (),
        DE_Value = 0
            && DR_Value = 0
            && PCC_Value = 0, "Color1",
        DE_Value = 0
            && DR_Value = 0
            && PCC_Value > 0, "Color2",
        DE_Value = 0
            && DR_Value > 0
            && PCC_Value = 0, "Color2",
        DE_Value = 0
            && DR_Value > 0
            && PCC_Value > 0, "Color3",
        DE_Value > 0
            && DR_Value = 0
            && PCC_Value = 0, "Color3",
        DE_Value > 0
            && DR_Value = 0
            && PCC_Value > 0, "Color4",
        DE_Value > 0
            && DR_Value > 0
            && PCC_Value = 0, "Color4",
        DE_Value > 0
            && DR_Value > 0
            && PCC_Value > 0, "Color5",
        "other"
    )

 

vkongfanfmsft_0-1709002000364.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-kongfanf-msft
Community Support
Community Support

Hi @jcastr02 ,

 

Based on your description, it appears that you want to classify states into groups based on specific conditions and then apply unique color codes to those groups. Here is a step-by-step approach to accomplish this in Power BI:

 

StateCategory = 
VAR DE_Value =
    MAX ( 'Table'[DE_Column] )
VAR DR_Value =
    MAX ( 'Table'[DR_Column] )
VAR PCC_Value =
    MAX ( 'Table'[PCC_Column] )
RETURN
    SWITCH (
        TRUE (),
        DE_Value = 0
            && DR_Value = 0
            && PCC_Value = 0, "Color1",
        DE_Value = 0
            && DR_Value = 0
            && PCC_Value > 0, "Color2",
        DE_Value = 0
            && DR_Value > 0
            && PCC_Value = 0, "Color2",
        DE_Value = 0
            && DR_Value > 0
            && PCC_Value > 0, "Color3",
        DE_Value > 0
            && DR_Value = 0
            && PCC_Value = 0, "Color3",
        DE_Value > 0
            && DR_Value = 0
            && PCC_Value > 0, "Color4",
        DE_Value > 0
            && DR_Value > 0
            && PCC_Value = 0, "Color4",
        DE_Value > 0
            && DR_Value > 0
            && PCC_Value > 0, "Color5",
        "other"
    )

 

vkongfanfmsft_0-1709002000364.png

 

Best Regards,
Adamk Kong

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.