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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
djillbunters
Frequent Visitor

Matrix table with measures as rows - conditional formatting on specific Column only

Dear all,

 

I have an annoying but useful Matrix table, which I use to calculate Actual, Budget, Delta & LY.

Each row is a measure and using a disconnected table I determined my columns.

 

Now I want to, if possible, apply conditional formatting on values ONLY in the Delta column.

It seems not possible?

djillbunters_0-1709566825462.png

 

Example formula for the Total Revenue:

Total Revenue = 
VAR __Category = SELECTEDVALUE('DisconnectedTable'[Classification], BLANK())
VAR SelectedType = SELECTEDVALUE(Sheet1[Type])

VAR __Result =
SWITCH( TRUE(),
__Category = "Actual",
-SUMX(
FILTER('BudgetActual',
[Classification] = "Actual" &&
RELATED(GLAccountClassification[Index]) IN {1,2}
),
[Amount]
),
__Category = "Budget",
-SUMX(
FILTER('BudgetActual',
[Classification] = SelectedType &&
RELATED(GLAccountClassification[Index]) IN {1,2}
),
[Amount]
),
__Category = "Delta",
-SUMX(
FILTER('BudgetActual',
[Classification] = "Actual" &&
RELATED(GLAccountClassification[Index]) IN {1,2}
),
[Amount]) -
-SUMX(
FILTER('BudgetActual',
[Classification] = SelectedType &&
RELATED(GLAccountClassification[Index]) IN {1,2}
),
[Amount]
),
__Category = "LY",
-SUMX(
FILTER(ALL('BudgetActual'),
[Classification] = "Actual" &&
RELATED(GLAccountClassification[Index]) IN {1,2} &&
YEAR(BudgetActual[Date]) = YEAR(MAX(BudgetActual[Date])) - 1 &&
MONTH(BudgetActual[Date]) IN VALUES('Date'[Date].[MonthNo])
),
[Amount]
),
// Default case for any other value of __Category
BLANK()
)

RETURN
__Result
Maybe I'm going all wrong about it?

Maybe I should start over and use a Measure for Actual, Delta, Budget, LY instead, and use a different table for a hierarchy?

I did it this way because the person I'm making it for likes to see things in a very specific way.

My P&L Forecast I built differently with just 1 measure and some custom DAX for GROSSMARGIN etc... (as it's a calculation and not a GL account):
djillbunters_1-1709567144003.png



Preferably I would like to not start over, but if that's what needs to be done then so be it 🙂

 

Thanks in advance!


EDIT:
Could i create a custom measure that either calculates whether it should apply (only if = "Delta") and use this measure in the conditional formatting formula?
 

 

1 ACCEPTED SOLUTION

Hi @djillbunters 

You need to set the condition at different measures, it cannot be put in one measure, you need to set it with multiple measure.

If you want to implement it in one measure, you need to put all your one measures in one measure, you can refer to the following solution.

1.Create a table,put all the measure names to the table. then put the column of the table to the row of the matrix. the column  of the table visual don't change.

vxinruzhumsft_0-1709689310098.png

vxinruzhumsft_1-1709689642961.png

2.Create a measure,and put the measure to the value of the matrix.

 

Measure =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Table'[Type] ) = "Total Revenue", [Total Revenue],
    SELECTEDVALUE ( 'Table'[Type] ) = "COGS", [COGS],
    SELECTEDVALUE ( 'Table'[Type] ) = "Gross Margin", [Gross Margin]
)

 

3.Then create a measure to set the format.

 

Measure2 =
IF (
    SELECTEDVALUE ( 'DisconnectedTable'[Classification] ) = "Delta"
        && [Measure] < 0,
    "red"
)

 

Put the measure2 to the conditional formatting of the measure.

vxinruzhumsft_2-1709689843803.png

 

Best Regards!

Yolo Zhu

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

 

 

 

 

Best Regards!

Yolo Zhu

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

4 REPLIES 4
v-xinruzhu-msft
Community Support
Community Support

Hi @djillbunters 

It can be set directly.

e.g for the total revenue, you can create a measure. 

Measure =
IF (
    SELECTEDVALUE ( 'DisconnectedTable'[Classification] ) = "Delta"
        && [Total Revenue] < 0,
    "red"
)
)

Then put it to the conditional formatting of the [Total Revenue] measure.

vxinruzhumsft_0-1709617476497.png

 

Best Regards!

Yolo Zhu

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

Thank you, this seems to work!
However I'm struggling to put the entire logic in 1 measure.
So I can use 1 measure as conditional formatting on each measure in my table.
But this does not seem to work 

CondFormat_Delta =

VAR SelectedMeasure = SELECTEDMEASURE()

RETURN

IF (

    SELECTEDVALUE ( 'DisconnectedTable'[Classification] ) = "Delta"

        && SelectedMeasure < 0 ,

    "red")



Hi @djillbunters 

You need to set the condition at different measures, it cannot be put in one measure, you need to set it with multiple measure.

If you want to implement it in one measure, you need to put all your one measures in one measure, you can refer to the following solution.

1.Create a table,put all the measure names to the table. then put the column of the table to the row of the matrix. the column  of the table visual don't change.

vxinruzhumsft_0-1709689310098.png

vxinruzhumsft_1-1709689642961.png

2.Create a measure,and put the measure to the value of the matrix.

 

Measure =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Table'[Type] ) = "Total Revenue", [Total Revenue],
    SELECTEDVALUE ( 'Table'[Type] ) = "COGS", [COGS],
    SELECTEDVALUE ( 'Table'[Type] ) = "Gross Margin", [Gross Margin]
)

 

3.Then create a measure to set the format.

 

Measure2 =
IF (
    SELECTEDVALUE ( 'DisconnectedTable'[Classification] ) = "Delta"
        && [Measure] < 0,
    "red"
)

 

Put the measure2 to the conditional formatting of the measure.

vxinruzhumsft_2-1709689843803.png

 

Best Regards!

Yolo Zhu

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

 

 

 

 

Best Regards!

Yolo Zhu

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

Quite elegant solution! And works great.
Thank you very much

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors