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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
sridhar71
Helper I
Helper I

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.

sridhar71_0-1667327027362.png

 

Let me know if this is possible

1 ACCEPTED SOLUTION

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.
mariussve1_0-1667332761995.png

 

Br

Marius

View solution in original post

12 REPLIES 12
sridhar71
Helper I
Helper I

This is the measure I created.

sridhar71_0-1667331694878.png

 

It is located under the main table.

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

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

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
 

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.
mariussve1_0-1667332761995.png

 

Br

Marius

You are a genius.

 

it is working now

sridhar71_0-1667333357889.png

 

please email it to sramaswamy71@gmail.com

I have now emailed you the working .pbix file as agreed 🙂

Br

Marius

mariussve1
Solution Supplier
Solution Supplier

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

Thanks for reply.

 

How will the measure be applied after we create it?

Hi again,

 

When you are in the conditional formatting pane you need to choose field value in the format style:

 

https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-conditional-table-formatting#color...

Marius

I tried that and it is not letting me choose the measure as an option

sridhar71_0-1667331395336.png

 

After I click on Color Measure

sridhar71_1-1667331417616.png

 

Can you put the measure in the Matrix and ensure there is no error in it? When I have the issue of choosing measure in the field value its because the measure has error in it

 

Marius

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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