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
username777
New Member

2 factor text conditional formatting

Hi all,

 

 

Will very appreciate help building the following visual in PowerBi:

 

Matrix that looks like below:

 

 Group1Group2Group3Group4
Class1     25354525
Class2     15652545
Class3     16281514
Class4     19171919
Class5     24233539

 

 

I need to highlight with the background colour focus Class-Group combinations. E.g. Class2 in Group1 is focus, so I need to highlight cell with value 15 - the condition would be "if class variable is equal class2 and group variable is equal group1 then value should be highlighted with green"

 

If I understand correctly, it can be possible to do with DAX + conditinal formatting but coulnd't unfortunately find any example.

 

May be anyone has something similar to share?

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@username777 , Not very clear.

 

But you can create a color measure and use that in conditional formatting using "Field Value" Option

 

example measure

Color  = if(FIRSTNONBLANK('Table'[Year],2014) <=2016 && AVERAGE(Sales[Sales Amount])<170 
,"lightgreen",if(FIRSTNONBLANK('Table'[Year],2014)>2018,"red","yellow"))
Color sales = if([Sales Today] -[sales yesterday]>0,"green","red")

color =
switch ( true(),
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity1" && sum('Table'[Value]) >500,"lightgreen",
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity2" && sum('Table'[Value]) >1000,"lightgreen",
// Add more conditions
"red"
)

 

 

refer : https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@username777 , Not very clear.

 

But you can create a color measure and use that in conditional formatting using "Field Value" Option

 

example measure

Color  = if(FIRSTNONBLANK('Table'[Year],2014) <=2016 && AVERAGE(Sales[Sales Amount])<170 
,"lightgreen",if(FIRSTNONBLANK('Table'[Year],2014)>2018,"red","yellow"))
Color sales = if([Sales Today] -[sales yesterday]>0,"green","red")

color =
switch ( true(),
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity1" && sum('Table'[Value]) >500,"lightgreen",
FIRSTNONBLANK('Table'[commodity],"NA") ="commodity2" && sum('Table'[Value]) >1000,"lightgreen",
// Add more conditions
"red"
)

 

 

refer : https://radacad.com/dax-and-conditional-formatting-better-together-find-the-biggest-and-smallest-num...
https://docs.microsoft.com/en-us/power-bi/desktop-conditional-table-formatting#color-by-color-values

Thanks a lot! This helped me to do what I wanted. 

 

 

Do you know if it is possible now to count somehow the amount of cells that are of particular color? 

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.