Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Conditional color by product

Hi, how to create a measure to have the below color criteria?
If the Product = Product A & [Average hours] > 30 then "red", if Product = Product B & [Average hours] > 25, "Red", else "Green"

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    Please try the measure below:

    Color Criteria = 
    SWITCH(
        TRUE(),
        SELECTEDVALUE( 'Table'[Product] ) = "A" &&SELECTEDVALUE('Table'[Average hours])> 30, "red",
    SELECTEDVALUE( 'Table'[Product] ) = "B" &&SELECTEDVALUE('Table'[Average hours])> 25,"red","green"
    )

     

    Then you can follow these steps to set font color.

    1.Click the column you want to apply the conditional color.

    2.Under the “Format by” options >choose Field value>

     

    3.Choose Color Criteria in "Based on field" pane and click ok.

     

    You will get a chart like below:

     

    A sample PBIX. for your reference is attached

     

    Hope it helps,


    Community Support Team _ Caitlyn Yan

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

     

     

4 Replies

  • selimovd's avatar
    selimovd
    Icon for Most Valuable Professional rankMost Valuable Professional

    Hey Anonymous ,

     

    you can do that with the following measure:

    Color Criteria =
    SWITCH(
        TRUE(),
        MAX( myTable[Product] ) = "Product A" & [Average hours] > 30, "red",
        MAX( myTable[Product] ) = "Product B" & [Average hours] > 25, "red",
        "Green"
    )

     

    If you need any help please let me know.
    If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
     
    Best regards
    Denis
     
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi selimovd , why I can't select this measure under the font color?

      • selimovd's avatar
        selimovd
        Icon for Most Valuable Professional rankMost Valuable Professional

        Hey Anonymous ,

         

        I don't know, can you post a screenshot? It should be possible to select it.

         

        Best regards

        Denis

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try the measure below:

    Color Criteria = 
    SWITCH(
        TRUE(),
        SELECTEDVALUE( 'Table'[Product] ) = "A" &&SELECTEDVALUE('Table'[Average hours])> 30, "red",
    SELECTEDVALUE( 'Table'[Product] ) = "B" &&SELECTEDVALUE('Table'[Average hours])> 25,"red","green"
    )

     

    Then you can follow these steps to set font color.

    1.Click the column you want to apply the conditional color.

    2.Under the “Format by” options >choose Field value>

     

    3.Choose Color Criteria in "Based on field" pane and click ok.

     

    You will get a chart like below:

     

    A sample PBIX. for your reference is attached

     

    Hope it helps,


    Community Support Team _ Caitlyn Yan

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