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
Mous007
Helper IV
Helper IV

Conditional formatting with DAX for all columns

Hi all,

 

I am trying to conditionally format all the columns on my table. I can do each column manually but i am trying to be more efficient as i have more than 25 columns on my tables.

 

All the columns should have a background color based on the following rules:

 

1) Show red background color for any column cell with a value <> Blank OR value > 0

2) show green or no color background color for any color cell = Blank

 

A screen shot is also provided below.

ss1_censored.jpg

 

 

Is there any possible way i can format all column at once without having to do it individually for each column please ?

 

Any leads/hints would be highly appreciated.

 

Best,

Mous

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Mous007 ,

Create a color measure like the give example

Color Date = if(FIRSTNONBLANK('Date'[Date],TODAY()) <today(),"lightgreen","red")

Color Date =
var _min =minx(allselected(Date,Date[Year])
return
 Switch( true(),
 FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"lightgreen",
  FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"blue",
 "red")

if(FIRSTNONBLANK(Table[Value],"true")= "true","green","red")

 

Use this with field option in color formatting of all the columns

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

3 REPLIES 3
Anonymous
Not applicable

Sadly, for conditional formatting there is NO option to format all columns in one go. You have to go through them one by one. I know about it because I've done a similar research myself before.

Best
D

Thank you guys.

 

Seems like some manual work is inevitable in this situation ...

amitchandak
Super User
Super User

@Mous007 ,

Create a color measure like the give example

Color Date = if(FIRSTNONBLANK('Date'[Date],TODAY()) <today(),"lightgreen","red")

Color Date =
var _min =minx(allselected(Date,Date[Year])
return
 Switch( true(),
 FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"lightgreen",
  FIRSTNONBLANK('Date'[Year],year(TODAY()))-_min =0 ,"blue",
 "red")

if(FIRSTNONBLANK(Table[Value],"true")= "true","green","red")

 

Use this with field option in color formatting of all the columns

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

 

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.

Top Solution Authors