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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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