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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Theo1403
Advocate I
Advocate I

Apply conditional formatting on a matrix based on other value in the matrix

Hi all,

 

I created a matrix that shows the accounts receivable and accounts payable balances for several companies in a group. The values come from a transaction table that consists of all the accounts payable and accounts receivable transactions for all of the companies. The row and column values in the matrix come from different columns in that same transaction table. I want to apply conditional formatting to the matching (green) and not matching (red) values. Therefor I need a measure that sums the balance in the current cell and the balance in related cell (for example: company 2 has an A/P balance on company 1, which matches the A/R balance of company 2 on company 1). The end result should look like the picture attached. This shoud be possible, but I am completely stuck...

Theo1403_0-1721822546813.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Theo1403 

 

Here I create a set of sample for your reference:

vzhengdxumsft_0-1721873081339.png

Write a measure and drag it to a matrix:

_Sum = SUM('Table'[Value])

vzhengdxumsft_1-1721873157753.png

Then add a measure:

Color =
VAR _currentCompany1 =
    MAX ( 'Table'[Company1] )
VAR _currentCompany2 =
    MAX ( 'Table'[Company2] )
RETURN
    IF (
        [_Sum]
            + CALCULATE (
                [_Sum],
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Company1] = _currentCompany2
                        && 'Table'[Company2] = _currentCompany1
                )
            ) <> 0,
        "Red",
        "Green"
    )

 

Click the [_Sum] and select the Background color in the Conditional formatting:

vzhengdxumsft_2-1721873291746.png

Then select the Field value in Format style box and select the [color] in the what field should we base this on?

vzhengdxumsft_3-1721873395155.png

The result is as follow:

vzhengdxumsft_4-1721873539719.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Theo1403 

 

Here I create a set of sample for your reference:

vzhengdxumsft_0-1721873081339.png

Write a measure and drag it to a matrix:

_Sum = SUM('Table'[Value])

vzhengdxumsft_1-1721873157753.png

Then add a measure:

Color =
VAR _currentCompany1 =
    MAX ( 'Table'[Company1] )
VAR _currentCompany2 =
    MAX ( 'Table'[Company2] )
RETURN
    IF (
        [_Sum]
            + CALCULATE (
                [_Sum],
                FILTER (
                    ALLSELECTED ( 'Table' ),
                    'Table'[Company1] = _currentCompany2
                        && 'Table'[Company2] = _currentCompany1
                )
            ) <> 0,
        "Red",
        "Green"
    )

 

Click the [_Sum] and select the Background color in the Conditional formatting:

vzhengdxumsft_2-1721873291746.png

Then select the Field value in Format style box and select the [color] in the what field should we base this on?

vzhengdxumsft_3-1721873395155.png

The result is as follow:

vzhengdxumsft_4-1721873539719.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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