cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

Multiple column color formatting

Azim
Level II

I have multiple columns both numerical and characters. I want to color format for all numeric columns. 

 

My first attempt was using if function 

Local ({dt},
dt = Data Table ("Cpk report overall");
dt << Begin Data Update;
For Each Row(
If(
:"Row 1"n >= 1.33, :"Row 1"n << Color cells ("Green", Row()),
(:"Row 1"n < 1.33) & (:"Row 1"n >= 1.06), :"Row 1"n << Color cells ("Yellow", Row()),
:"Row 1"n < 1.06, :"Row 1"n << Color cells ("Red", Row())
)
);
dt << End Data Update;
);

Please ignore my column name as it is the product of transposing a column.. 

 

But this method will only apply for 1 of the many columns I have and will have which will not be consistent. Is there a way to make this work for all column without having to specify column names?  

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User


Re: Multiple column color formatting

You will want to loop over the columns

Names Default To Here(1);

dt = Data Table("Cpk report overall");
collist = dt << Get Column Names("Numeric", "Continuous");
dt << Begin Data Update;

For Each({colname}, collist,
	For Each Row(
		If(
			:"Row 1"n >= 1.33, :"Row 1"n << Color cells("Green", Row()),
			(:"Row 1"n < 1.33) & (:"Row 1"n >= 1.06), :"Row 1"n << Color cells("Yellow", Row()),
			:"Row 1"n < 1.06, :"Row 1"n << Color cells("Red", Row())
		)
	);
);

dt << End Data Update;

but in this case I would consider trying Color Gradient column property instead of coloring cells using << Color Cells

jthi_0-1729156685933.png

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User


Re: Multiple column color formatting

You will want to loop over the columns

Names Default To Here(1);

dt = Data Table("Cpk report overall");
collist = dt << Get Column Names("Numeric", "Continuous");
dt << Begin Data Update;

For Each({colname}, collist,
	For Each Row(
		If(
			:"Row 1"n >= 1.33, :"Row 1"n << Color cells("Green", Row()),
			(:"Row 1"n < 1.33) & (:"Row 1"n >= 1.06), :"Row 1"n << Color cells("Yellow", Row()),
			:"Row 1"n < 1.06, :"Row 1"n << Color cells("Red", Row())
		)
	);
);

dt << End Data Update;

but in this case I would consider trying Color Gradient column property instead of coloring cells using << Color Cells

jthi_0-1729156685933.png

 

-Jarmo
Azim
Level II


Re: Multiple column color formatting

Thank you!

 

I overlooked such a convenient "Color Gradient" and "Standardized Attributes"!