This post is an answer to Owen’s question about progress bars:
“How can I do conditional red, yellow & green coloring? Can’t I just do a nested IF statement? [...] I’d like the bar to move and change color, all based on the value of the % Complete column.”
Though nested IF statements are an option, in this case the CHOOSE function will provide a more elegant solution, easier to read.
The first formula below has a choice of 11 colors. The choice will be decided by “INT([%]*10)+1″, an integer function of the % complete column (0% returns 1, 100% returns 11).
Update [October 29] I have added a non-breaking space to both formulas. This is needed in Firefox.
="<DIV style='position:relative;'><DIV style='background-color:"&CHOOSE(INT([%]*10)+1,"red","red","OrangeRed","OrangeRed","DarkOrange","Orange","Gold","yellow","GreenYellow","LawnGreen","Lime")&"; width:"&([%]*100)&"%;'> </DIV><DIV style='position:absolute; top:0px;'>"&TEXT([%],"0%")&"</DIV></DIV>"
Another example with only three colors:
="<DIV style='position:relative;'><DIV style='background-color:"&CHOOSE(INT([%]*3)+1,"red","Orange","Lime","Lime")&"; width:"&([%]*100)&"%;'> </DIV><DIV style='position:absolute; top:0px;'>"&TEXT([%],"0%")&"</DIV></DIV>"
For other examples of conditional formatting, check this post about color coding.

14 comments
Comments feed for this article
October 23, 2008 at 9:06 pm
Links for 10/23/08 « Steve Mullen’s Blog
[...] Path to SharePoint: Progress bar + color coding [...]
October 28, 2008 at 5:02 am
Websites tagged "progressbar" on Postsaver
[...] – Progress bar + color coding saved by theperson182008-10-25 – Web progress bar saved by amachang2008-10-20 – Firefox Plugin: [...]
October 29, 2008 at 6:35 am
Printable progress bars « Path to SharePoint
[...] A second option is to modify the formula and use colors instead of background colors, or use images. Here is an example of workaround for the above screenshot, where I used border colors (instead of background colors in the original post): [...]
November 29, 2008 at 4:06 am
Anonymous
Great Stuff!
August 7, 2009 at 7:35 am
Anonymous
Thanks! It looks great!
August 12, 2009 at 10:36 am
Effie
Good job!
who can you do that for the gantt view? say you have a task that pass the due date, and still not compeled?
August 15, 2009 at 8:44 am
Christophe
Effie, see if one of these two examples inspires you:
http://pathtosharepoint.wordpress.com/2009/07/22/an-example-combining-gantt-view-and-color-coding/
http://pathtosharepoint.wordpress.com/2008/10/29/gantt-view-first-test/
November 2, 2009 at 1:42 pm
Visualization – calculated color gradients « Path to SharePoint
[...] The CHOOSE function is more elegant than nested IFs, and is a natural choice when dealing with multiple options. You’ll find all the explanations to achieve a color gradient in this post. [...]
May 11, 2010 at 5:20 am
Case study: course compliance report (Part II) « Path to SharePoint
[...] Christophe brought to my attention I was missing the non breaking space discussed in this post Progress bar + color coding. Now it made sense why it wasn’t working correctly in FF. I made the simple change and [...]
May 21, 2010 at 7:09 am
Solo
How can I add background image instead of background color
point 1) How can I adjust my image width depend on a value
December 10, 2010 at 7:15 pm
Ade
Kindly break this down for me, I’m a total newbie and I think I’m doing quite well. Successfully done an IF statement for color coded pictures and bullets.
Trying to achieve a star format dashboard where the middle circle shows the entire company performance and the outer circles represent the department. I’ve got this working, I’ve successfully hidden the column headers to it looks nice but I don’t know how to add text beside the bullets. I don’t know any HTML.
The bullets show the traffic lights but I want to show the department name and possibly the percentage if possible right beside the bullet. Can you help?
Thanks.
April 14, 2011 at 7:35 pm
peter
what type of column would i be creating? calculated,lookup,etc
September 21, 2011 at 4:25 pm
Victoria Houghton (@Vhoughton)
What am I doing wrong? I get “The formula refers to a column that does not exist. Check the formula for spelling mistakes or change the non-existing column to an existing column.”
I’d love to add the 11 colour progress bar, I’ve add the CEWP and the script from the “Using calculated columns to write HTML” page.
you’re advice would be grately appreciated!
November 13, 2011 at 11:24 pm
Christophe
Double check your spelling, it seems that you didn’t type the column name correctly.