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
Anonymous
Not applicable

If statement conditional formatting based on two field values

Hi there,

 

I have a matrix visual below. I want to set up conditional formatting based on the value of the different types. For example, University Connection should have a colored background if the sum of January is below 2, but Street Team should have a background color if the sum of any month is below 4, and social media post below 12. The values are the same for each month but different for each type and I have 14 types total.

 

Is this possible? If so, can someone point me to a video or documentation? 

 

Screen Shot 2022-07-20 at 10.51.58 AM.png

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

>>  I want to set up conditional formatting based on the value of the different types. For example, University Connection should have a colored background if the sum of January is below 2, but Street Team should have a background color if the sum of any month is below 4

You can try this, create the measure below

 

Condition formatting = 
var _type=MIN('Table'[Type])
var _month=MIN('Table'[Month])
return
SWITCH(TRUE(),
_type="University Connection",IF(CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Month]=_month&&'Table'[Type]=_type))<2,1),
_type="Street Team",IF(CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Month],'Table'[Type]))<4,1))

 

When type="University Connection", this measure sums the value of January, and judges whether it is less than 2. If it is, it returns 1.
When type="Street Team", sum the value of each month, and judge whether it is less than 4, if so, return 1.

then, create the measure

 

Measure = IF([Condition formatting]=1,"yellow")

 

vxiaotang_0-1659583218878.png

vxiaotang_1-1659583253623.png

In matrix, since row and column do not support conditional formatting, we set conditional formatting for value.

and if you have many types, then I'm afraid you'll have to manually add other types of rules in the first measure.

vxiaotang_2-1659583420124.png

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @Anonymous 

Thanks for reaching out to us.

>>  I want to set up conditional formatting based on the value of the different types. For example, University Connection should have a colored background if the sum of January is below 2, but Street Team should have a background color if the sum of any month is below 4

You can try this, create the measure below

 

Condition formatting = 
var _type=MIN('Table'[Type])
var _month=MIN('Table'[Month])
return
SWITCH(TRUE(),
_type="University Connection",IF(CALCULATE(SUM('Table'[Value]),FILTER(ALL('Table'),'Table'[Month]=_month&&'Table'[Type]=_type))<2,1),
_type="Street Team",IF(CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Month],'Table'[Type]))<4,1))

 

When type="University Connection", this measure sums the value of January, and judges whether it is less than 2. If it is, it returns 1.
When type="Street Team", sum the value of each month, and judge whether it is less than 4, if so, return 1.

then, create the measure

 

Measure = IF([Condition formatting]=1,"yellow")

 

vxiaotang_0-1659583218878.png

vxiaotang_1-1659583253623.png

In matrix, since row and column do not support conditional formatting, we set conditional formatting for value.

and if you have many types, then I'm afraid you'll have to manually add other types of rules in the first measure.

vxiaotang_2-1659583420124.png

 

Best Regards,

Community Support Team _Tang

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

Anonymous
Not applicable

Yay! So that got me halfway there. It's not allowing me to enter a specific row. Do you know how I should format the formula to change only the row I want?

 

If I change [type] to [Street Team], it says it cannot find the name.

 

Screen Shot 2022-07-20 at 11.43.54 AM.png

amitchandak
Super User
Super User

@Anonymous ,

Create a color measure and use that in conditional formatting using the field value option

 

if( [Street Team] < 4 && [social media] <12, "Red", "White")

 

How to do conditional formatting by measure and apply it on pie?
https://www.youtube.com/watch?v=RqBb5eBf_I4&list=PLPaNVDMhUXGYo50Ajmr4SgSV9HIQLxc8L
https://community.powerbi.com/t5/Community-Blog/Power-BI-Conditional-formatting-the-Pie-Visual/ba-p/1682539

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

ay! So that got me halfway there. It's not allowing me to enter a specific row. Do you know how I should format the formula to change only the row I want?

 

If I change [type] to [Street Team], it says it cannot find the name.

 

Screen Shot 2022-07-20 at 11.43.54 AM.png

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!

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.