Forum Discussion

JoyceW's avatar
JoyceW
Icon for Helper II rankHelper II
4 years ago
Solved

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:

 

 

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:

 

 

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. 

 

 

  • 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"
        )
    )
    

     

5 Replies

  • PaulDBrown's avatar
    PaulDBrown
    Icon for Community Champion rankCommunity 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"
        )
    )
    

     

  • DataZoe's avatar
    DataZoe
    Icon for Microsoft Employee rankMicrosoft 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"

    )

    • JoyceW's avatar
      JoyceW
      Icon for Helper II rankHelper II

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

      • DataZoe's avatar
        DataZoe
        Icon for Microsoft Employee rankMicrosoft Employee

        JoyceW Can you provide more details?

        Here I have it set up like this:

        And [PL Amount] is like this: