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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
andybrace
Frequent Visitor

DAX Measure for conditional formatting - problem with filter context

Hi,

 

On another post I found a solution to create a measure that can be used for conditional formatting:

 
ColourMeasure =
VAR _SELName = VALUES('tbl_MD_Business Matrix for Summary'[Global SBU - Std#])
RETURN
IF(MAX('tbl_MD_Business Matrix'[Global SBU - Std#]) IN _SELName,"Black","White")
 
The idea is to have a matrix with all businesses listed and then the one selected with the slicer on  'tbl_MD_Business Matrix for Summary'[Global SBU - Std#] will be highlighted using conditional formatting.
 
This was working fine, but then the report user asked for the slicer on 'tbl_MD_Business Matrix for Summary'[Global SBU - Std#] to only show the businesses in scope for their view (filtered on another higher level business slicer from an alternate table).  To do that I had to create some joins that ended up with the results being filtered but the matrix was only showing the one business selected.  I fixed that by editing the filter interactions.  But now I have told the matrix to ignore the filter context the formatting measure no longer works.

I assume I need to use something like KEEPFILTERS on the VAR _SELName??  But I can't work out the syntax.
 
Or maybe there is a better way to achieve the same thing?
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @andybrace ,

 

You could add the filter conditions by using CALCULATETABLE() and FILTER() function.

For example:

VAR _SELName =
CALCULATETABLE (
VALUES ( 'tbl_MD_Business Matrix for Summary'[Global SBU - Std#] ),
FILTER (
ALLSELECTED ( 'tbl_MD_Business Matrix for Summary' ),
'tbl_MD_Business Matrix for Summary'[business]
= SELECTEDVALUE ( 'alternate'[business] )
)
)

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @andybrace ,

 

You could add the filter conditions by using CALCULATETABLE() and FILTER() function.

For example:

VAR _SELName =
CALCULATETABLE (
VALUES ( 'tbl_MD_Business Matrix for Summary'[Global SBU - Std#] ),
FILTER (
ALLSELECTED ( 'tbl_MD_Business Matrix for Summary' ),
'tbl_MD_Business Matrix for Summary'[business]
= SELECTEDVALUE ( 'alternate'[business] )
)
)

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to assist you. I cannot use screenshots of your source data.

Please show the expected outcome based on the sample data you provided. Screenshots of the expected outcome are ok.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.