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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jonbox
Helper II
Helper II

Query to change background colour

Hi, I'm looking for a query that changes the background colour of cells based on the value of cells in a particular column:

 

In the below i'd like to show the "Jul score" as red or green. green if it = to "count of goals", red if it doesn't.

jonbox_0-1641562123154.png

 

Similarly,

if you drill down into the matrix, these should also have a background colour based on the results of the "Count of Goals" column.

 

e.g., fixed asset management = red becasue count of goals = 6 and july score = 2

however inventory = red becasue count of goals = 4 and july score = 4.

jonbox_1-1641562179805.png

 

Hope that is clear! thanks in advance.

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@jonbox So, will depend on whether these are columns or measures. Let's say Count of Goals is using the Goals column and Jul score is a measure, then you could create a measure like:

Measure = IF(COUNT([Goals]) = [Jul score],1,2)

You could then use Conditional formatting to change the background color. You would choose Jul score in the Visualization field well, right-click, Conditional formatting, Background color. Use the new measure as the "What field should we base this on?" setting.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

@jonbox So, will depend on whether these are columns or measures. Let's say Count of Goals is using the Goals column and Jul score is a measure, then you could create a measure like:

Measure = IF(COUNT([Goals]) = [Jul score],1,2)

You could then use Conditional formatting to change the background color. You would choose Jul score in the Visualization field well, right-click, Conditional formatting, Background color. Use the new measure as the "What field should we base this on?" setting.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
mh2587
Super User
Super User

IF(Count of Goal = Jul score,"Green","Red")


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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