Forum Discussion

sridhar71's avatar
sridhar71
Helper I
3 years ago
Solved

Conditional formatting for each matrix row

I have a Matrix table that shows Inventory turnover for each Vendor.

I want to know If I have different conditions for each Vendor.

For Ex if the value or Vendor1 >= 300 then use orange but for Vendor2 use Green

If the value goes below 100 for Vendor 4 then use red but do not apply the same rule for other vendors.

 

Let me know if this is possible

  • I have uploaded a test .pbix file that are working.

    Does not look like I have possibilites to upload the file. If needed, I can email it to you. Please let me know.


    My measure looks like this: (Could you try to change yours as well, and use AND () instead of &.

    Color measure =
    SWITCH (
        TRUE(),
        AND ( SELECTEDVALUE('Table'[Vendor]) = "Vendor1", SUM ( 'Table'[Value] ) = 100 ), "#e30b5d",
        AND ( SELECTEDVALUE('Table'[Vendor]) = "Vendor2", SUM ( 'Table'[Value] ) = 200 ), "#8e4585",
        AND ( SELECTEDVALUE('Table'[Vendor]) = "Vendor3", SUM ( 'Table'[Value] ) = 150 ), "#077106",
        AND ( SELECTEDVALUE('Table'[Vendor]) = "Vendor4", SUM ( 'Table'[Value] ) = 300 ), "#09387f",
        AND ( SELECTEDVALUE('Table'[Vendor]) = "Vendor5", SUM ( 'Table'[Value] ) = 200 ), "#5851db"
    )
     
    I have added a snipping tool of the result, and it works as expected.

     

    Br

    Marius

12 Replies

  • Hi,

    You can create a measure to be used with conditional formatting;

     

    Color measure =
    SWITCH ( TRUE(),

    SELECTEDVALUE (Table[In charge]) = "Vendor1" & SUM(Table[ValueColumn]) >= 300, "#F3F2F1",

    SELECTEDVALUE (Table[In charge]) = "Vendor2" & SUM(Table[ValueColumn]) >= 200, "#666666"

    )

     

    Br

    Marius

  • This is the measure I created.

     

    It is located under the main table.

    What do you mean by "put the measure in the matrix"?

    • mariussve1's avatar
      mariussve1
      Solution Sage

      In the table/matrix where you gonna have the conditional formatting, put the color measure in the value field. Just to ensure its not throwing a error measure.

      This is for debugging purpose only

      • sridhar71's avatar
        sridhar71
        Helper I

        This is the error I got

        "Calculation error in measure 'npa_invtry_qty'[Color measure]: DAX comparison operations do not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values."

         

        This is my DAX

        Color measure =
        SWITCH ( TRUE(),
        SELECTEDVALUE (npa_invtry_qty[INVTRY_STATUS]) = "Forecast" & [Total Quantity New]>= 300, "#F3F2F1",
        SELECTEDVALUE (npa_invtry_qty[INVTRY_STATUS]) = "Actual" & [Total Quantity New] >= 200, "#666666"
        )
         
        Total Quantity New is a Measure