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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors