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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
JoyceW
Helper II
Helper II

Conditional formatting on specific row in matrix based on the value in that row

Hi, 

 

I've created a P&L statement in Power BI, by using a model in Excel and used that for a matrix table. 

 

This is the model:

 

Schermafbeelding 2022-08-14 om 16.41.05.png

 

Then I created several measures. The measure that is added to the matrix is this one:

 

BEDRAGEN =
VAR KEUZE = SELECTEDVALUE('MODEL_RESREK'[Item])
Return
SWITCH(TRUE(),
KEUZE = "OMZET", [OMZET TOTAAL],
KEUZE = "KOSTPRIJS TOTAAL", [INKOOPWAARDE TOTAAL],
KEUZE = "BRUTO-RESULTAAT", [BRUTO-RESULTAAT],
KEUZE = "KOSTEN TOTAAL", [KOSTEN TOTAAL],
KEUZE = "NETTO-RESULTAAT", [NETTO-RESULTAAT],
CALCULATE(Meting[TOT_BEDRAGEN], FILTER(KOPPELING, KOPPELING[Sub-categorie]=keuze)))

 

The matrix works:

 

Schermafbeelding 2022-08-14 om 16.46.16.png

 

Now for NETTO-RESULTAAT I want to conditionally format, where the background of a positive number is green and a negative number is red. 

 

All I've managed so far is turning the entire row Yellow with this measure and then using it as a conditional formatting on BEDRAGEN:

 

color = if(max(MODEL_RESREK[Item_lay-out]) ="NETTO-RESULTAAT", "Yellow", "White")

 

So how do I get to the next step? Any help is very much appreciated. 

 

 

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

Try:

 

color =
IF (
    AND ( MAX ( MODEL_RESREK[Item_lay-out] ) = "NETTO-RESULTAAT", [BEDRAGEN] < 0 ),
    "Red",
    IF (
        AND ( MAX ( MODEL_RESREK[Item_lay-out] ) = "NETTO-RESULTAAT", [BEDRAGEN] > 0 ),
        "Green",
        "White"
    )
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

Try:

 

color =
IF (
    AND ( MAX ( MODEL_RESREK[Item_lay-out] ) = "NETTO-RESULTAAT", [BEDRAGEN] < 0 ),
    "Red",
    IF (
        AND ( MAX ( MODEL_RESREK[Item_lay-out] ) = "NETTO-RESULTAAT", [BEDRAGEN] > 0 ),
        "Green",
        "White"
    )
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






DataZoe
Employee
Employee

@JoyceW 

 

Have you tried something like this:

 

color =
SWITCH( TRUE(),
max(MODEL_RESREK[Item_lay-out]) ="NETTO-RESULTAAT", "Yellow",
[BEDRAGEN] > 0, "Green", 
[BEDRAGEN] < 0, "Red", 
"White"

)

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Hi, this somehow turned all the other rows green and the row NETTO-RESULTAAT is still yellow. 🙂

@JoyceW Can you provide more details?

Here I have it set up like this:

DataZoe_0-1660595618061.png

And [PL Amount] is like this:

DataZoe_1-1660595782990.png

 

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

Thanks for the detailed answer. It's hard for me to explain sometimes, since I'm still a beginner. Paul's solution worked!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.