Forum Discussion
Conditional formatting for each row in Power BI matrix
I have a matrix visual :
Row: Product
Columns: MonthYear
Values: UnitCost
For P1 If UnitCost 0-10 -> Red , 10-40-> Yellow, 40+Green
For P2 If UnitCost 0-20 -> Red , 20-30-> Yellow, 30+Green
For P3 If UnitCost 0-10 -> Red , 10-50-> Yellow, 50+Green
For P4 If UnitCost 0-20 -> Red , 10-40-> Yellow, 40+Green
When I am trying to do this conditional formatting for P1, I am getting all the P1, P2, P3, and P4 with the same color coding.
Can we get color coding for each row as per the above problem statement?
4 Replies
- MahyarTF
Memorable Member
Hi,
Add the column to your table with below script :
Color =if ( Sheet70[ProductName] = "P1" && Sheet70[UnitCost] >= 0 && Sheet70[UnitCost] < 10, "Red",if ( Sheet70[ProductName] = "P1" && Sheet70[UnitCost] >= 10 && Sheet70[UnitCost] < 40, "Yellow",if ( Sheet70[ProductName] = "P2" && Sheet70[UnitCost] >= 0 && Sheet70[UnitCost] < 20, "Red",if ( Sheet70[ProductName] = "P2" && Sheet70[UnitCost] >= 20 && Sheet70[UnitCost] < 30, "Yellow",if ( Sheet70[ProductName] = "P3" && Sheet70[UnitCost] >= 0 && Sheet70[UnitCost] < 10, "Red",if ( Sheet70[ProductName] = "P3" && Sheet70[UnitCost] >= 10 && Sheet70[UnitCost] < 50, "Yellow",if ( Sheet70[ProductName] = "P4" && Sheet70[UnitCost] >= 0 && Sheet70[UnitCost] < 20, "Red",if ( Sheet70[ProductName] = "P4" && Sheet70[UnitCost] >= 20 && Sheet70[UnitCost] < 40, "Yellow", "Green"))))))Then use it in your Conditional formatting :- amikm
Helper V
Thanks, MahyarTF,
I have replicated the DAX in my Power BI report, but in conditional formatting, the calculated column that I have created is grayed and I am not able to use it.
I have created the calculated column in the tabular model itself as my report is connected live with the tabular model ( cube). Also, UnitCost is measure in my case that is showing data for Unitsold in 7 days- MahyarTF
Memorable Member
Hi,
Have you tried my solution?
Thanks for Kudos