Color coding is very useful to highlight key items in a list. For example in an issues list, you may want to draw the users’ attention on items with high priority.
In the picture below, I have aggregated 4 different ways to do it:

This customization was entirely done through the SharePoint UI. Let’s see how.
The method
I am simply going to apply my post about using calculated columns to write HTML. For each example, we need to figure out the formula that will create the HTML string. Then the script, included in a CEWP, will make it behave as real HTML.
The formulas
In my example, I am applying color coding based on the priority of each issue: red for high, yellow for normal and green for low. Note that the formulas below were built for an issues list, formulas for other lists or libraries may be slightly different.
So here we go, please refer to the above picture to see the result:
- Traffic light (actually a big bullet!):
=”<DIV style=’font-weight:bold; font-size:24px; color:”&CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)&”;’>•</DIV>”
- Indicator (reusing the default SharePoint KPI images):
=”<DIV><IMG src=’/_layouts/images/KPIDefault-”&(3-RIGHT(LEFT(Priority,2),1))&”.gif’ /></DIV>”
- Font color:
=”<DIV style=’font-weight:bold; font-size:12px; color:”&CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)&”;’>”&Priority&”</DIV>”
- Background color:
=”<DIV style=’font-size:12px; background-color:”&CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)&”;’>”&Priority&”</DIV>”
Simply paste your preferred formula in a calculated column, add the script on the Web page as explained here, and voila!
Update: check out this post for more step by step examples!

163 comments
Comments feed for this article
September 23, 2008 at 4:01 pm
Amita
Hi! This is great. We’ve been needing something like this in the past. We’ve had to open up SharePoint Designer in order to get it to work like the way you did. The one question I had is what if you want to base the color coding off a different column? We wanted to base it off a status column (open, closed, in progress, etc.) and I’ve been unable to change your code to fit that. Any words of wisdom?
September 23, 2008 at 5:29 pm
Christophe
Thanks Amita
In your case, instead of CHOOSE you can use IF statements. For example:
IF( [status]=”open”, “red”, IF([status]=”in progress”, “orange”, “green”))
September 23, 2008 at 8:38 pm
Amita
Thanks! That worked like a charm.
September 25, 2008 at 4:33 pm
Amita
Have you thought about applying the color coding to other sorts of lists, like a calendar? Our clients are always looking for ways to implement color coding into the calendar web part.
September 25, 2008 at 8:59 pm
Ryan
When I use the Traffic Light method the column width is very large. Is there a way to control the width?
September 25, 2008 at 9:54 pm
Applying color coding to SharePoint list : Justgeeking
[...] http://pathtosharepoint.wordpress.com/2008/09/01/apply-color-coding-to-your-sharepoint-lists/ [...]
September 25, 2008 at 11:44 pm
Christophe
Amita: I am working on enlarging the scope of this method, and I hope to publish updates in the weeks to come. That’s what I already did for grouped views, based on the feedback on my initial script.
For calendars: I have nothing ready yet. For now, you can play with the script – for example replace ((TDContent.indexOf(“<DIV”) == 0) with ((TDContent.indexOf(“<DIV”) <=12) and see what happens. Also, see Ben Bradley’s comment here:
http://pathtosharepoint.wordpress.com/2008/09/01/using-calculated-columns-to-write-html/
September 25, 2008 at 11:48 pm
Christophe
Ryan: what do you mean by “very large”? One way to reduce the width is to use a shorter column name, for example “!” or “::”.
You should also be able to include the width in the formula, though I haven’t tried it myself.
September 29, 2008 at 7:18 pm
Veenus
Thank you for this post. I’ve tried other codes provided by different posts with no luck. I actually applied your code and it’s working beautifully.
I’m not a developer by trade so I need further assistance from you. I’m trying to apply it against the % Complete column (>=.9,”GREEN”, etc.) and I’m not sure on how to change the code to make it work. I used the indicator code but I received broken images. Can you help me with this?
Thanks in advance!
September 29, 2008 at 7:46 pm
Veenus
I figured it out. I got the formula to work using Nested IF statements.
September 30, 2008 at 12:18 am
Christophe
OK. I’m glad you find this post helpful
September 30, 2008 at 11:39 am
Benjamin
Very very nice!
September 30, 2008 at 6:14 pm
Lynnda Harley
I am trying to use the IF statement above instead of Choose – not the best with code: Status is the field and WIN, LOST are choices….
=”•”
September 30, 2008 at 6:50 pm
Lynnda Harley
This worked for me. Thank you – I love this site….
“=”" “
October 17, 2008 at 7:55 am
My SharePoint scripts tested in Safari « Path to SharePoint
[...] Color coding: OK [...]
October 17, 2008 at 5:15 pm
Should you replace Excel with SharePoint lists? (Part II) « Path to SharePoint
[...] A couple comments: – the choice Excel vs. SharePoint list is not exclusive, there are bridges between the two options. Some Excel spreadsheets can be imported to a SharePoint list, and most SharePoint lists have an “Export to Excel” feature. There is even a free add-in for Excel-SharePoint synchronization: http://msdn.microsoft.com/en-us/library/bb462636(office.11).aspx - It’s not all black or white. For example SharePoint also has some charting capabilities: you can take advantage of free Flash or Silverlight tools, or apply color coding to your lists. [...]
October 21, 2008 at 8:53 am
Progress bar + color coding « Path to SharePoint
[...] For other examples of conditional formatting, check this post about color coding. [...]
October 22, 2008 at 11:20 am
Pat
Christophe,
For months now my boss wanted me to color code a list we maintain to highlight priority and status. Until I discovered your website, I could not get it done. You went above and beyond what anyone else has ever done in helping us overcome some pitfalls and glitches (self-inflicted). Thank you for your commitment to making SharePoint a tool we can use in a more tailored fashion.
October 23, 2008 at 9:15 pm
Anonymous
I am definitely a novice when it comes to Sharepoint development, so bear with me here.
I have a calculated column in a Sharepoint List called “Days Overdue” and I am trying to create another column called “Overall Status” which compares the information in the Days Overdue column and sets it to a green or red background based upon the information present. I can get it to work for text – that’s about it.
=IF([Days Overdue]>-1,”Red”,”Green”)
Can someone provide some assistance? Thanks!
October 24, 2008 at 10:15 am
Christophe
In my examples, the color is decided by the function:
CHOOSE(RIGHT(LEFT(Priority,2),1),”red”,”orange”,”green”)
Simply replace it with your function: IF([Days Overdue]>-1,”Red”,”Green”)
Just curious: how do you determine the “days overdue”?
October 24, 2008 at 1:40 pm
Anonymous
Hmm it’s still not working and this is what I have…
=”-1,”Red”,”Green”)&”;’>”&[Days Overdue]&”"
Sample of what I see from table:
71
As you can see, when I view my table I am getting text instead of 71 with a background color of Red. Any other thoughts? I know my company is using an older version of Sharepoint which doesn’t have all of the bells & whistles as compared to the newer version.
As far as your question:
You can trick sharepoint into creating a column for today’s date which you can then compare today’s date to another date (in this case revised date). As a result, I created a column for “Today”, with single line of text and then created another calculated column “CalcToday” and set it equal to the “Today” column. Once I was done I deleted the “Today” column and voila! You have a column which is set to the current date! Then I just created the “Days Overdue” column which compares date information from certain items to be addressed/completed (a.k.a”Revised Date”) to “CalcToday”.
October 24, 2008 at 1:45 pm
Anonymous
LoL fail. Formula isn’t posting as desired…if you have e-mail Christophe I can send it to you…essentially I took the same information from your background formula and inserted the if statement and also modified the end &Priority& section for Days Overdue.
October 24, 2008 at 2:08 pm
Christophe
First, I recommend this post:
http://pathtosharepoint.wordpress.com/2008/08/14/calculated-columns-the-useless-today-trick/
(off-topic for color coding, but relevant to your case)
Then, make sure your double quotes are correct (type them directly in the formula field, do not copy/paste from the post).
And of course feel free to contact me directly at Christophe@PathToSharePoint.com
October 24, 2008 at 7:49 pm
Anonymous
Figured it out – was missing the script in the code to change information to HTML. It works perfectly. Your site and overall guidance has ben great. Thank you!!!
October 28, 2008 at 7:58 am
The “HTML calculated column”: stay tuned! « Path to SharePoint
[...] that you first read this series. You’ll learn how, thanks to a simple script, you can: – apply color coding to your issue lists – create progress bars for your task lists – enhance your contact lists – open hyperlinks in a new [...]
October 30, 2008 at 2:04 pm
Dishaniti
Hello
I try to implemente indicator in my infopath form library using following formula as “My Severity” column name.
=”"
here field name is “Form Severity” which contain High, Low, Medium values. As this field contain spaces in field name, so I have used field with square bracket as [Form Severity].
I have also added HTML in CEWP.
Once I implement this in any view , it is giving me #VALUE! under “My Severity Column”.
Can anyone suggest me whats wrong I am doing?
Disha
October 30, 2008 at 2:09 pm
Dishaniti
3-RIGHT(LEFT([My Severity],2),1))&”.gif’
I try to post my formula 2-3 times, somehow it is trimming from the post
October 30, 2008 at 2:10 pm
Dishaniti
what is the best way to post my formula here
October 30, 2008 at 2:37 pm
Christophe
Dishaniti: to post your formula, replace the angle brackets with another character. Or contact me by e-mail at Christophe@PathToSharePoint.com
October 31, 2008 at 4:54 pm
Inferno
I am trying to put a traffic lights column on a task list. I’ve copied your code to the CEWP as it is on the site. When I go to make my calculated column this is what I use
”
=IF([drop test]=”Red”,”http://sharepoint…/Red.bmp”,IF([drop test]=”Green”,”http://sharepoint…/Green.bmp”,”wrong”))
”
[drop test] is a choice column.
This work but only that it shows a link to the picture and not the picture, what do I need to change so it will work with your code and display a picture
November 1, 2008 at 2:39 am
Troubleshooting your “HTML calculated column” « Path to SharePoint
[...] of your calculated column. – Start by implementing one of my examples as is. Choose for example the indicator, which works on a standard issues list. – You can use the “Edit in Datasheet” option to [...]
November 11, 2008 at 6:39 pm
Inferno
I have tried your example and it doesn’t quite work either. I used your CEWP code, made an issues list with a title and priority. I used your calculated column code for the calc column (=”•”)
It works for the logic but the pictures don’t show.
Priority Normal(2) returns this exactly:
Priority High(1) returns this exactly:
November 11, 2008 at 10:38 pm
Christophe
There is a troubleshooting section here:
http://pathtosharepoint.wordpress.com/2008/11/01/troubleshooting-your-html-calculated-column/
Let me know if this is helpful.
November 15, 2008 at 9:16 am
SharePoint calendars: color coding, hover effects, etc. « Path to SharePoint
[...] “HTML calculated column“. You may find the following posts particularly useful: – some simple but useful examples to get started – a troubleshooting section – how to apply the method to the [...]
December 9, 2008 at 1:10 pm
Color coding: more examples « Path to SharePoint
[...] already published an article about color coding for SharePoint lists three months ago, and its sibling for calendar views last month. Both rely on the same client side [...]
December 19, 2008 at 5:29 am
Brian
I fall into the group of trying to use this in a custom list (I believe that’s what we created/imported) rather than an issues list. I fooled around with this for a good hour, realized we imported a spreadsheet hence the “custom list” list definition and base type. I finally setup the demo issue list to keep my sanity and confirmed I was doing it right.
Any idea what needs to be changed to get it working in a custom list?
Thanks, great info though!
Brian
December 19, 2008 at 5:40 am
Christophe
Brian, I have published a bunch of new examples recently, see which one is closest to your case:
http://pathtosharepoint.wordpress.com/2008/12/09/color-coding-more-examples/
December 19, 2008 at 7:28 am
Demi
Hi Christophe, thanks for sharing the tips.
I had tried your method and it works fine. However, when I tried to print it out, the colour have gone. Do you know how to print with the highlighted backgroup color in it as well?
Many thanks.
December 19, 2008 at 7:45 am
Christophe
Demi, this is the expected behavior. The following post should answer your question:
http://pathtosharepoint.wordpress.com/2008/10/29/printable-progress-bars/
See the whole series for other examples:
http://pathtosharepoint.wordpress.com/category/the-html-calculated-column/
For example, a printable calendar:
http://pathtosharepoint.wordpress.com/2008/11/15/sharepoint-calendars-color-coding-hover-effects-etc/
December 19, 2008 at 10:15 am
Demi
Hi Christophe, I tried and it works but the problem is I don’t have a fixed size for the cell like the example given. The size of the column cell have to depend on the “Texts” that entered by my user. In this case do you know how to make it flexible?
January 7, 2009 at 8:33 pm
Important References - No Programming « Sharepoint Programming
[...] http://pathtosharepoint.wordpress.com/2008/09/01/apply-color-coding-to-your-sharepoint-lists/ Possibly related posts: (automatically generated)Machine History Sharepoint ControlsHow to Create a SharePoint Web Part [...]
January 8, 2009 at 12:46 pm
Rudy
Hi Christophe, I have a birthday list, which has a employee name column and current year birthday column, This current year birthday column is used to extract the birthday month and date and put it in birthday column, however, I want to highlight the particular birthday in the list on the particular birthday date. please suggest me a way to do.
January 8, 2009 at 5:02 pm
Christophe
Rudy: I’d suggest to keep it simple and display two views of the list, one filtered with birthday=[Today] and the other with birthday!=[Today].
If for some reason you need to keep all names in one list, you can leverage this post:
http://pathtosharepoint.wordpress.com/2008/11/24/countdowns-a-second-method/
January 9, 2009 at 7:53 am
Rudy
However, I want to highlight a birthday when birthday=[today], but I am not able to apply the if condition on the list, please suggest
January 9, 2009 at 8:17 am
Christophe
Again, see the link I suggested. Birthdays are just a particular case of countdown where nothing happens before or after the date, and the field is highlighted the day the date is reached.
Browse other posts in this blog to find examples of highlighted fields.
January 9, 2009 at 8:27 am
Rudy
I have used these steps to create the birthday list
Create a Custom List for your Team Roster/Key Contacts. Add columns for Name, Role, and whatever other information you are tracking.
2. Create a Custom Column for “Current Year Birthday” column as a Date data type to display Date Only.
3. Create a Custom Column for “Birthday” column as a Calculated data type to calculate a Text data type with the following formula:
=TEXT([Current Year Birthday],”mm/dd”)
4. Create a Custom Column for “Current Month” column as a Calculated data type to calculate a Date data type with the following formula:
=DATE(YEAR([Current Year Birthday]),MONTH([Current Year Birthday]),1)
5. Create a Custom Column for “Next Month” column as a Calculated data type to calculate a Date data type with the following formula:
=DATE(YEAR([Current Year Birthday]),MONTH([Current Year Birthday])+1,1)
6. Create a New View on the Custom List that displays the Title and Birthday columns and filters on the following criteria:
[Current Month] is less than or equal to [Today] AND
[Next Month] is greater than [Today]
Display: Name, Birthday
Sort: Birthday, Ascending Order
7. Add a List View Web Part for the Custom List to a page that uses the View created in Step 6.
however, it only show birthday for particular month, now i want to highlight the current date birthday with particular color, please suggest how the same can be achieved
January 12, 2009 at 10:34 am
Rudy
Christophe, please help
January 14, 2009 at 8:57 pm
Andrew
You can do this through SharePoint UI? Can you post some instructions?
I am trying to flag items in a data view. For example if ‘Amount > $500′, I want to highlight it red. Or flag it in some way.
January 14, 2009 at 10:58 pm
Christophe
Andrew, the instructions are in the post, and you’ll find more examples to help you here:
http://pathtosharepoint.wordpress.com/2008/12/09/color-coding-more-examples/
January 16, 2009 at 12:52 am
Ralph
Hi Christophe, first of all, I wanted to thank you for all your hard work and for giving us solutions to our SharePoint related issues. I have implemented your example for the colors, and it works beautifuly.
There is one issue though that I am not being able to resolve. If you try to filter on a grid to see only Green bullets (for example) all you see is the HTML code “<DIV style ….". Is there anyway to see either the bullets or a friendly text? I have tried to input comments on the begining of the HTML code like:
=" <DIV style=’font-weight:bold;……"
But it didn’t work. Do you have any idea how to implement this?
Thanks in Advance,
Ralph
January 16, 2009 at 12:58 am
Ralph
My code that I just posted, didn’t post correctly because I had a comment tag
=”B_ “&IF(Status=”Completed”, “green”, “red”)& “E_ <DIV style=’font-weight:bold; font-size:24px;….."
where B_ is the begining of the comment tag.
where E_ is the end of the comment tag.
Thanks
January 16, 2009 at 3:34 pm
Christophe
Ralf: the only friendly text I can think of is “This column cannot be filtered”… and this is possible by setting the “filterable” attribute to false.
I have done some tests to try and display the HTML (bullet or other). I am able to do it for simple cases. I’ll try to improve it and share my findings this month.
July 23, 2009 at 3:14 am
Anonymous
Hi Christophe,
Many thanks for your great posts. Just wondering if you ever managed to get a workable solution going for filtering on the “traffic lights”?
steve.
January 16, 2009 at 9:19 pm
Ralph
Thanks for your answer…I was able to do it, the problem was because I was putting the code to have the comment before the and the java-script expects to be in the position 0.
So, all I had to do was put it after the …it doesn’t look great, but it is better than nothing.
I will send you the image by email.
Thanks again
January 19, 2009 at 8:52 pm
sadalit
I just implemented this solution for a client on a SharePoint task list and it is working wonderfully. The best thing about it for me is that the “traffic light” code allowed me to use colors other than red/yellow/green, which was the client’s request. Merci mille fois, Christophe, for the solution and code!
January 25, 2009 at 9:16 am
Tal Winter
Genious!
How can I donate?
Thank you very much for the code, you are such a genious.
January 26, 2009 at 7:03 pm
Anonymous
Hello Christophe,
I am trying to create a ‘Traffic Light’ status indicator for tasks using the % Complete. I have been unsuccesful at creating the script in the calculated column for this. I kept getting a Syntax error. Would you mind taking a look at my script and see what I did wrong?
January 27, 2009 at 1:06 am
Christophe
Sure, send me an e-mail: Christophe@PathToSharePoint.com
January 27, 2009 at 7:38 pm
Anonymous
Thank you so much for this post. It has been super helpful. The execs definitely like a color coded pretty SharePoint dashboard over a mono-chromatic one.
January 29, 2009 at 10:44 pm
Peter
God you are the man! I’ve been searching for a solution to this.. thank you for being kind enough to post the solution.
January 29, 2009 at 10:46 pm
Peter
If you have time.. How would you code it if you want 0-3 ?
I was thinking –
”CHOOSE((RIGHT(LEFT([Expected User Impact],2),1),0)”green”,”yellow”,”orange”,”red”)
Of course it’s not working though..
January 30, 2009 at 3:59 am
Christophe
RIGHT(LEFT(column,2),1) extracts the first character: 1,2 or 3.
If your choice is 0-3, then replace it with:
RIGHT(LEFT(column,2),1)+1
and add a color choice.
I also suggest that you check out the following post, it has lots of examples to play with:
http://pathtosharepoint.wordpress.com/2008/12/09/color-coding-more-examples/
February 4, 2009 at 4:50 pm
Kirti
Hi Christophe,
I’m not a programmer by profession, but a PM trying to set up a risk mgmt list in sharepoint. I have a field called color and I’m trying to have its color changed based on the value of a field called “Weight”. I created the color column as a calculated field and put the following formula in it:
=IF([Weight]<=6,”GREEN”,IF([Weight]<=11,”yellow”,”red”))
Now I’m not sure where exactly to write the web part. I opened up the list, chose the CEWP from site actions, and am confused as to what code to write in it, and also howwould the web part know which field’s color I’m trying to change?? Sorry if this sounds too dumb, but any help you can provide would be very appreciated. the above foormula dispalys the word “GREEN” or “red” appropriately, but does not show any color in the color field. Thanks so much.
February 4, 2009 at 5:07 pm
Christophe
Kirti: you are on the right path. As you are just getting started with this, I recommend this page where the examples are more detailed:
http://pathtosharepoint.wordpress.com/2008/12/09/color-coding-more-examples/
For the code in the CEWP, simply follow the links in the post. It may look like a maze, this is because color coding is just one application, the scope of the method is actually much broader.
Hope this helps. If you need more details let me know!
February 4, 2009 at 8:47 pm
Kirti
Hi Christophe,
Thanks for your help on this. It works (finally!) in the standard view. However, when i view it in the datasheet view, it still shows the HTML and not the color. I looked in the datasheet view and iv can see the CEWP code there, so am not sure what else is missing. Any suggestions?
Thanks so much.
February 5, 2009 at 1:50 am
Christophe
The method only works with HTML. It won’t work in datasheet view which is an ActiveX control – specific to Internet Explorer.
February 5, 2009 at 5:27 pm
Colleen
This collection of posts has been invaluable. I have several “dashboards” that have benefited from this. Thank you so much Cristophe!
February 8, 2009 at 11:06 am
Anonymous
Hi Chris,
Which feature should i enable to add the html in Calculated Field.
rgds.
February 9, 2009 at 4:56 pm
Kirti
Hi Cristophe,
The color coding works when i use your code.
I am trying to set up the field to show a bullet (trafic light) as well as show the name of the color next to it (since we have some color blind folks here). It does that correctly, except that if i reduce the font size to 12, it also reduces the size of the bullet. How can i change the lettering to 12 while still keep it as a big bullet. Please respond only if you have time, since i know that this is something that i may be able to find in an HTML manual as well. Thanks so much.
February 10, 2009 at 2:24 am
Christophe
Kirti: right, an HTML manual will help you write more advanced formulas.
For your case, you’ll need to use two SPAN tags, each with its own font size.
As an example, take a look at this:
http://pathtosharepoint.wordpress.com/2008/10/29/gantt-view-first-test/
February 12, 2009 at 8:32 pm
Anonymous
I am trying to use the bullet point formula on SharePoint 2003 server. what happens is I get the html code instead of the colored bullet point any ideas?
Thanks
J
February 14, 2009 at 10:05 pm
TJ Doherty
Christophe -
Excellent articles on how to do this stuff. I’ve adapted some of your work for a client and in the process discovered a number of things. First, in your KPI Indicator example above, you use an indexing of 1, 2, 3 for the indicators. I have a WSS 3.0/MOSS 2007 installation and found out that the default indexing is really 0, 1, 2. I also found lots more KPI Indicators that I discuss in my blog (http://tjdoherty.spaces.live.com/blog/cns!4FFA26922BDE54A3!405.entry). Keep up the good work and thanks for your assistance in helping me help a client.
February 15, 2009 at 1:35 pm
TJ Doherty
Christophe -
Please disregard my earlier comment. Not being familiar with the formula you used for constructing the KPI Indicator (KPIDefault-”&(3-RIGHT(LEFT(Priority,2),1))&”.gif’ />”). I thought the math it was doing was 3-(2 or 1) resulting in either a 3, a 2, or a 1 index number. Now I realize that the math is 3-(the 2nd character of “Priority”, of length 1) which will result in either a 0, a 1, or a 2.
Sorry, I did not mean to intentionally disparage your excellent work.
February 17, 2009 at 5:02 am
links for 2009-02-16 | Alpesh Nakar Blogs on SharePoint, Microsoft and that's IT
[...] Apply color coding to your SharePoint lists Color coding is very useful to highlight key items in a list. For example in an issues list, you may want to draw the users’ attention on items with high priority. (tags: sharepoint howto) [...]
February 17, 2009 at 6:23 pm
Alexandra Mandis
HI Christophe
I have a Status Field, like Amita, and want to display GREEN, YELLOW, RED based on the value of the status. I have tried replacing your &CHOOSE with the IF example you gave and SP thinks there is an error in the formula. Here is my formula – see anything wrong?
=”•”
where Goal Confidence is the status field.
Any help would be appreciated
February 18, 2009 at 2:04 pm
netta
hi,
I tried applying the font code to a different column then the priority one but it just doesn’t seem to work. i keep getting a syntax error.
this is the IF statement that i made
=IF([On Time Status]=”Overdue”, “red”, IF([On Time Status]=”On time”, “orange”, “green”))
but I’m not sure how to past it in the the original code :
=””
just doesn’t work. what am i doing wrong ?
February 18, 2009 at 2:20 pm
Christophe
netta, follow the link at the end of the post, you’ll find more step by step examples showing you how to continue once you have selected the color.
Your first formula seems technically OK, I just don’t understand why “on time” is associated with orange.
February 18, 2009 at 9:49 pm
Eric Laliberte
Christophe,
This is awesome stuff.
I know too little about HTML. I tried to copy your code, but the result of the calculated column is showing the HTML rather than formating it.
My formula:
=”"&[Serial Number]&”"
Result:
3001302813-010-1
Any ideas? Thanks
Eric
February 18, 2009 at 10:11 pm
Eric Laliberte
Please ignore my post. I didn’t fully understand http://pathtosharepoint.wordpress.com/2008/09/01/using-calculated-columns-to-write-html/ . Sorry to waste your time.
Eric
February 19, 2009 at 2:50 pm
Eric Laliberte
Christophe,
Using the code below, I was hoping the calculated columns would produce dates. I do have Sharepoint set to the date data type.
//=”"&[Notf Date]&”"
Instead of getting 2/17/2009, I get 39861 conditionally formated correctly.
Do you have any ideas?
Eric
February 19, 2009 at 2:51 pm
Eric Laliberte
Trying this to display the code.
“&[Notf Date]&”
February 20, 2009 at 3:13 pm
larry
I am posting this here because you are using the CHOOSE function. My question related to, I think, CHOOSE. While we create these colorful fields I have found that you can not add “SUM” these values, because it is not just a number, it is am entire string. Looking at my string it ends the same way. my integer and two closing DIV tags. Can the CHOOSE function or any function allow me to grab just my integer so I can sum multiple calculated values?
Example:
[DIV ....][DIV...]0.234[/DIV][/DIV] can I grab the 0.234 from the string? It may not be 3 decimal places, but will always be between the DIVs
February 20, 2009 at 6:37 pm
Anonymous
Have you tried using either MID or a combination of LEFT and RIGHT to select just the digit and then convert it to an integer before using SUM? Excel has a VALUE function that convert a number string to an actual number value. I think I was able to use it in a calculated column. Just be prepared, your formula may get very long. I suggest creating columns for the intermediate steps. And then once you get it all working, you can combine the formulas in all the columns.
February 21, 2009 at 1:59 am
Christophe
Looks complicated. *Anonymous* is correct, use a combination of LEFT and RIGHT, and also FIND and SEARCH. On top of this don’t forget VALUE to convert your 0.234 from string to number…
I assume 0.234 is pulled from somewhere else, so why not just use the original column?
February 22, 2009 at 3:56 pm
Anonymous
Thanks for the great code. One quick question. How can I center the text within the display column (I don’t want it left aligned).
February 23, 2009 at 1:15 am
Christophe
For more advanced HTML strings, I recommend to refer to a HTML tutorial, like w3schools.
I your case you’ll use the style attribute:
http://www.w3schools.com/html/html_styles.asp
You’ll need to set properties like “width=100%” and “text-align:center”. The exact expression will depend on the tags you use.
February 23, 2009 at 5:47 pm
Jim Bonwell
I’m using your script to highlight the title of a calendar item based up a selected category. When I change my calendar month view title to use my new highlighted title it breaks the <a href tags so there is no longer a link to that calendar item. Although the highlighting works great.
February 24, 2009 at 4:33 am
Christophe
Jim: for calendars, check out this post:
http://pathtosharepoint.wordpress.com/2008/11/15/sharepoint-calendars-color-coding-hover-effects-etc/
February 26, 2009 at 5:06 pm
Modificare modelli in Sharepoint Web Service 3 | hilpers
[...] Modificare modelli in Sharepoint Web Service 3 http://pathtosharepoint.wordpress.co…repoint-lists/ "Pisinho" <pisinho> wrote in message news:49a40698$1… > Salve, > sono [...]
March 5, 2009 at 11:40 am
Chris Sammut
Hi,
I am working on a document library and I wish to add indicators and colours as shown in your post. When I convert to an XLST data view to apply conditional formatting, the “edit in datasheet” dissapears from the actions menu.
Is there a way to resolve this issue or maybe another approach using the document library?
Thanks
Regards
Chris
March 5, 2009 at 11:55 am
Christophe
Chris, let me clarify a few points.
First, this post is NOT about the XSLT data view. We are talking about the standard SharePoint lists here.
Second, it is normal that you lose the “edit in datasheet” when you use the XSLT data view. The “edit in datasheet” is not HTML, it is a Microsoft control (which btw only works in IE).
Note that if you use my method, you’ll see that it doesn’t apply to “edit in datasheet” (for the same above mentioned reason).
March 11, 2009 at 7:54 pm
Brinton
So far so good – I managed to get my list working with the ‘Traffic Light’ style of indicators. Now I am trying the ‘Indicator’ style and can’t find the KPI default images that you refer to…
April 8, 2009 at 3:42 pm
Robin
At first: Thanks for your great work!
I try to paste the formula but I keep getting Syntax errors. I suspect it has something to do with the fact I have to use semicolons as separators, in stead of comma. I experienced this before with more simple formulas. I believe this has something to do with using non-us versions of WSS (although my SP language is english).
When I replace the comma’s with semicolons I still get the syntax error.
Do you know how I should adapt the formula, so that it works?
April 9, 2009 at 6:47 am
Christophe
Do not paste the formula, type it. My blog editor formats quotes in a way that is not suitable for SharePoint.
This was one of my first posts. In later posts I have included friendly “copy to clipboard” options (see for example the update at the end of the post).
April 9, 2009 at 3:42 pm
Robin
Thanks; this worked. But also i had to change the comma’s into semicolons.
April 13, 2009 at 2:59 pm
sadalit
Found this great site which lists all other color words that can be used:
http://plantphys.info/demo/Colors.html
April 14, 2009 at 12:37 am
Christophe
Sadalit: I did a quick check, and some colors are not correctly rendered on that page (e.g. puce and aliceblue).
My usual reference is w3schools. They have charts that help match text color and background. However, it seems that their list is not complete (puce is missing for example).
April 15, 2009 at 2:35 pm
Christophe
Hello Christophe,
When I try to apply the color coding to a calculated column supposed to display a date, I get as a result the date numeric value and not the date formatted value.
The calculated column has the following settings:
Data type returned: Date and Time
Date and Time Format: Date Only
The formula used is:
//=”30,”red”,IF([Date Difference]>5,”orange”,”green”))&”;’>”&[Planned Date]&”"
[Planned Date] has the value “31/03/2009″
[Date Difference] has the value of “0″
The calculated column shows “39903″ instead of “31/03/2009″ although the color is green (that part works fine).
Is there something that could be done or are dates not an option here?
Thanks for the help.
Christophe
April 16, 2009 at 1:08 am
Christophe
In calculations, dates are expressed in number of days. To get a date format, you’ll need to use functions like YEAR, MONTH and DAY.
See this article for references on calculated columns:
http://pathtosharepoint.wordpress.com/2008/08/07/calculated-columns/
And see this one for an example:
http://pathtosharepoint.wordpress.com/2008/11/24/countdowns-a-second-method/
April 17, 2009 at 4:04 pm
MSI-Linda
I have implemented this in many places…THANK YOU. Now I am doing one where they need me to on the VIEW “Group By” the Indicator column itself. When I Group By the indicator field I only see the HTML code, but if you expand the grouping I see the proper indicator lights underneath. So I assume I need to modify the Java Script??
April 21, 2009 at 6:18 am
Color Coding - Formula Generator « Path to SharePoint
[...] of the “HTML Calculated Column” method is color coding. This can be applied to SharePoint lists or [...]
April 21, 2009 at 8:20 pm
MSI-Linda
I still do not understand how to get it to render properly when the Indicator field is a “Grouped By” field in a view. It works fine if my indicator field is NOT the Grouped By field…but doesn’t render properly if I make it the Grouped By field.
April 23, 2009 at 10:18 am
Marcia
Hello all!
First of all, congratulations for this site!!!
I am trying to apply this formula to my Sharepoint site (v2):
=”"&Priority&”"
but I have the following message each time I try to validate:
“The formula contains a syntax error or is not supported.”
Everything works well for the v3 version (I have another site on this version and it works!).
Any idea?
Thank you very much for your help,
Marcia
April 23, 2009 at 10:20 am
Marcia
=”"&Priority&”"
Sorry, this is the right code…
Marcia
April 23, 2009 at 10:21 am
Marcia
//=”"&Priority&”"
April 29, 2009 at 10:06 am
Anonymous
This is not directly related with this topic but since it touches a similar subject…
I’m experiencing a problem with formulas, I have 2 farms running. On one of them I used the following formula “=IF([OSInstalled],0.75,0)” which works fine. I tried using the same formula on the other farm and I get the syntax error message.
I’ve tried switching the “,” to “;” and I still have the same problem.
The only difference between these farms is that 1 is x86 and the other is x64.
Any ideas?
Thanks
May 12, 2009 at 8:34 pm
Jenny
I can’t seem to figure out a way to remove commas from numeric values in SharePoint 2007 lists. ?
May 13, 2009 at 3:09 pm
Christophe
Jenny, check out the TEXT function in SharePoint calculated columns.
May 29, 2009 at 2:04 pm
JKlo
I would like to return the value of the Priority Column into the Font Color column, but remove the (1) from the value returned, so my colored text does NOT display (1) Low, but rather just Low
Using MID, the syntax for this “should” be: =”"&PullFrom&”"
this is accepted but returns #VALUE
Should I be using something different?
June 2, 2009 at 2:00 pm
Chris
This is great! Works perfectly! Does anyone know of a way to look up a column value from a previous version of a list item? Essentially, want to show previous priority of an item so you can see previous and current states. Thanks!
??
June 16, 2009 at 1:31 pm
Ken
I can get both the new code and the old code to work perfectly in my list, but when I try to bring my view from my list to a Webpart on another page it does not work. I have verified that I have used the same code on both pages, any ideas?
June 16, 2009 at 1:40 pm
Christophe
Ken, make sure you put the CEWP with the code after/under the Web Part on your other page. Apart from this, I see no reason why it wouldn’t work…except if you have some very specific customization on that other page that conflicts with my code.
June 16, 2009 at 2:02 pm
Ken
That was my first concern, so I pulled everything out and left just the Announcement List and the CEWP on the page, same issue.
I also started a new page and but the issue continues.
June 16, 2009 at 2:22 pm
Ken
Christophe,
Looking more into it I think I have narrowed something down.
My Test Page contains the Following:
Annoucements Web Part(List with color)
Calendar Web Part(with Color)
CEWP (TextToHtml)
CEWP (Mini Calendar)
My Color on the Calendar works both on the Calendar Page and in the Webpart
My Annoucements work fine on the annoucement Page but displays
background: test announcement
Instead of the color.
I can remove the Annoucment Webpart with no Issues, I can remove the Calendar webpart, and the mini calendar and the issue remains.
July 6, 2009 at 9:22 pm
Dean
How do I get this to work with the preview pane? This is my last hurdle. Thanks!
July 9, 2009 at 11:42 am
HTML Calculated Column – Updated script « Path to SharePoint
[...] check out these links: – the method, explained (includes version 1.0 of the script) – an example: apply color coding to lists – a formula generator for color coding – a troubleshooting [...]
July 10, 2009 at 10:00 pm
HTML Calculated Column – Updated script v2.1 « Path to SharePoint
[...] check out these links: – the method, explained (includes version 1.0 of the script) – an example: apply color coding to lists – a formula generator for color coding – a troubleshooting [...]
July 14, 2009 at 11:28 am
ash
Hi friends,
I am trying to use Traffic Light color code,
Pls let me know which code to be added to CEWP
July 15, 2009 at 6:02 am
Demi
Hi, would like to find out.
How to auto update the library information?
I have a Task Library, with a calculated column on Tasks’ Status with colour applied (using the colour coding method). The formula I used in the calculated column is to compare System Date with the Plan Date column. Actually it works pretty well. The only issue is the Task’s Status/colour will not get auto update if System Date is over than Plan Date.
Is there a way to refresh the Task records in the Task Library?
Thanks
Demi
July 17, 2009 at 6:23 pm
Brian Reeves
I noticed that when I used Bullets with a Task List % Complete that the bullets were slightly off set from the rest of the items. I solved it with a simple CSS addition of:
line-height:50%;
=”=0.8,”Green”,
IF([% Complete]>=0.6,”Yellow”,
IF([% Complete]•”
Great stuff! Thanks for all the help and code support!!
July 22, 2009 at 12:00 pm
An example combining Gantt view and color coding « Path to SharePoint
[...] screenshot utilizes the “Slider “ Web Part to facilitate a flexible view of the Gantt and the Text to HTML Web Part to add a visual status to the [...]
July 27, 2009 at 3:51 am
Sahil
Hi,
I am facing a problem that the filter on the view for the color coded column still show the tag. any idea if i can disable it in some way?
Regards,
sahil
July 30, 2009 at 7:59 pm
Tesh
Is it possible to perform the conditional formatting using a formula to is if the date in a column is less then or greater then todays date. Having are hard time getting around this since i can not use =Today in a calculated column
August 4, 2009 at 2:33 pm
Michael
We recently applied SP2 for MOSS. Since then, my color coded columns are not showing the colors. If I go into Edit Mode, then it is working again, but as soon as I exit Edit Mode, the background colors disappear. Any idea what is causing this and is there a work-around?
August 7, 2009 at 8:07 pm
Mike D.
What can I do if I do not access to CEWP??? Any other way to make it behave as real HTML???
August 13, 2009 at 7:06 pm
Dbo
Thanks for this great site!
I’m a complete newbie to SharePoint, but I’d like to use color coding on a task list I’m developing.
Do the examples above apply to SharePoint Portal Services 2003?
Thanks again!
August 15, 2009 at 9:07 am
Christophe
Dbo, the initial script published on September 1st 2008 worked with SP 2003. I would expect the latest versions to work with SP 2003 too, although I haven’t tested them.
October 8, 2009 at 1:24 pm
Dbo
Many thanks – it has worked great so far!
August 27, 2009 at 9:49 am
Staffan from Sweden
Hello!
I have created a custom list using Import spreadsheet. Im my original excel file I have column “A” color coded blue, column “B” yellow etc. My question is how to colorcode the different columns, not the rows. EG I want column called “Title” be blue, Column “Name” be yellow etc.
I only find how to color code a row, not how to colorcode a column.
I hope you understand my question and can help me out.
Many thanks in advantage
Staffan
September 1, 2009 at 4:28 pm
Christophe
The method allows you to color code one cell in a row. So if you simply apply the same color to all items, you should get your color coded column. Did I miss something?
September 1, 2009 at 1:53 pm
theerdman
I am having one minor quirk when i use the traffic light color coding. For some reason the bullet itself is wanting to push down in the cell causing the row to be off on spacing. I noticed that all of your data on the row for each of the calculated columns lines up exactly. What am i missing that is causing my bullet to be further down in the cell causing my spacing issues?
As always, great site and thanks for any and all assistance.
Ex. data data data
bullett
September 1, 2009 at 4:32 pm
Christophe
Are you calling me a cheater? Well, you’re right…by default a bullet will not be centered in the cell. So for the screenshot I applied some additional styles to the DIV element (a bottom margin or something like that).
September 3, 2009 at 3:49 pm
The HTML Calculated Column, one year later « Path to SharePoint
[...] been viewed more than 45,000 times, while its little sister explaining how to use the technique for color coding has been viewed 27,000 [...]
September 11, 2009 at 5:11 pm
Heidi
Hi Christophe,
This is really amazing. I can get everything to work properly except the Indicators. I seem to be misunderstanding the process. Can you please explain it a bit more. Thank you so much for everything – Heidi
September 11, 2009 at 5:58 pm
Heidi
Hello again, I can make the indicators work for the three different priorities. However, I need a fourth called Archived and that won’t work even though I made a shape for it that followed the naming convention for MOSS. We’re on WSS 3. Thanks again. This is just what we need!
September 11, 2009 at 7:05 pm
Heidi
Sorry to keep posting, but my problen was on my part. It was in the naming of the GIF files. One didn’t pass properly.
September 19, 2009 at 3:49 am
Jonathan
Hi Christophe,
This is an awesome tutorial. It’s very well written, and easy to follow. I have a different question that relates to this problem (color coding!)
Essentially, I’m in the process of building a sharepoint site to deal with emergencies we end up having on my military installation. One of the things I’ve created is a digital version of the checklists we use. Currently, the status of a checklist item is a choice box (Unset, NA, In-progress, On-going, or Completed). The viewable side is a Standard View of the checklist, and it’s edited by a Data Sheet View.
The boss wants the word “Completed” on the Standard View side to turn green when people using the Data sheet View switch it from “Unset” to “Completed.” Is there any way to accomplish this via CEWP or the XML version? I know your tutorial here calls for a Calculated column to change colors, but I’d like to try and avoid adding (yet another) column if at all possible.
I don’t care if it turns the entire row’s background green, or just the word “Completed.” I can explain away any weirdness provided it changes color. Unfortunately, being that it’s government computers on a Sharepoint server owned by a higher headquarters, I can’t go in and do it the easy way with Sharepoint Designer. Any help you could give me would be greatly appreciated. Thanks!
September 20, 2009 at 1:05 pm
Christophe
Jonathan: if you can’t use the DVWP and its conditional formatting, creating an additional calculated column seems to be the simplest approach.
You could also write a script that will search for the word “completed” on the page and turn the background green.
September 21, 2009 at 3:01 pm
theerdman
I am looking to do some of the field coding using calculated fields utilizing preexisting images included with sharepoint. Other than the KPI icons is there a way to view all the images included in the _layouts directory since DIRECTOR LISTING IS DENIED.
September 22, 2009 at 11:50 am
Heidi
Here is a link to a site that has images for viewing:
http://www.bitsofsharepoint.com/ExamplePoint/Site/SharePointLayoutImages.aspx
September 22, 2009 at 12:04 pm
Christophe
yep, thanks Heidi
September 23, 2009 at 1:57 pm
theerdman
One more question. Using this color idea is there a way to edit the form to show the same color as the calculated fields. For example, when i create a new entry for the list can the drop down field for priority show the same color or image as the calculated field in the view?
As always thanks for the help.
theerdman
October 11, 2009 at 1:36 pm
Christophe
Sure, you could do this, but it would be another customization, separate from the calculated column thing (the content of the calculated column is only created after you send the form).
September 26, 2009 at 8:31 pm
Phylme2
Wonderful information! I was wondering how would I use the ISERROR function with this. I am using this formula to capture if the projects have been baselined to show the overall health. However, if there is no baseline I would like the display to show “No Baseline”, or if I type nothing in for the Priority, I would like for it to display “No Baseline”, but definitely not the #Value erro. I hope this makes sense.
September 30, 2009 at 3:25 pm
TwoFries
Going back to one of the original posts using the IF statement, I am trying to change the background based on the value of a column called ‘RPN’
If the value is greater than 40 it should be red
If the value is greater than 20 is should be orange
Else it should be green. Here is the code that I have tried;
=”40,”red”,IF([RPN]>20,”orange”,”green”))’>”RPN&””
This is based on;
=IF(RPN>40,”red”,IF(RPN>20,”orange”,”green”))
which is successful, but when I try the HTML version I keep getting syntax errors but cant figure out why.
Any help would be greatly appreciated.
September 30, 2009 at 3:26 pm
TwoFries
The last comment did not have the proper code, here is what it should have been;
=”40,”red”,IF([RPN]>20,”orange”,”green”))’>”RPN&””
October 5, 2009 at 10:45 am
Christophe
TwoFries, it seems that an & is missing in your formula.
October 1, 2009 at 10:16 am
bingvillamor
Dear Sir,
I’m currently studying WSS 3.0 and I wanted to have a calculated column that will show a green traffic light if a column called COMMENCEMENT is ‘Y’. Below is what I have:
=”•”
When I create the calculated column, it shows a syntax error. Can you help?
October 1, 2009 at 10:19 am
Anonymous
=”•”
October 13, 2009 at 12:32 pm
Rich
Hi – i’ve applied the formula to traffic light status, and got nice coloured bullets appearing on my list. However, this only seems to work on the front page of hte sharepoint site. If i click into the different list views then only the html code displays, rather than the nice coloured bullets. Is there a way of ensuring the html conversion reaches the different list views?
Thanks
October 14, 2009 at 12:24 am
Christophe
Rich: the script is linked to a page, not to a list. To make it work with different views, you need to add the script to each view.
A good practice is to add the script before you create additional views. This way, you can reuse the first view with the script to build the others.
October 30, 2009 at 10:11 pm
rschedin
I have a similar issue as Rich. I’ve created an “In/Out” log and use the traffic lights script. I created several views for each team with no problem – the traffic light works fine. However when I create a “Personal View” for just myself I have the same issue as Rich – I only see the HTML. I tried adding the Text to HTML web part to the Personal view but with no success. Any thoughts?
October 21, 2009 at 3:51 pm
Carel
My create view is gona now, when i get it back by creating a new view but It’s all messed up. I get multiple lists with the same content when I create another view or list disaapears when I pick a certain view.
Anyway it gets REALLY messed up when you use this in the listpage
But great tip ofcourse
October 21, 2009 at 3:55 pm
Carel
Also can’t edit anymore in DataSheet either
October 22, 2009 at 12:24 pm
Christophe
Sorry, Carel, what are you talking about? I think this has nothing to do with the current post…
October 27, 2009 at 7:19 pm
Marina
Good day – I have a list that reflects dates of when folks post 4 different forms. Basically – the column headings are the names of the forms, to the left are the offices for which the forms were submitted. I’ve looked but didn’t see this post – but could have missed it. I’d like to set this list up where if a date in any of the 4 columns is older than 6 months – it is highlighted in red. Any info would be helpful. Thanks much.
October 28, 2009 at 12:25 pm
Christophe
Marina, search my blog for “countdown”, this will give you a start point. Comparing a date with today is not easy in SharePoint.
October 31, 2009 at 3:16 am
Christophe
@ rschedin: everything works fine on my tests. Could you precise what changes you made in personal view?
November 2, 2009 at 6:19 pm
Anonymous
From the View drop down I choose “Create View”. I then “Start From Existing View”. From the “Create View” page I give the view a name, click the “Create a Personal View” radio button, select filter criteria (which is to filter on the Name column and enter my name). The view comes up like I want – with just my entry but the “Traffic Light” only has the HTML showing.
What I want is for each staff member to create a view with just the entry for their name on the list.
I’ve tried adding the TextToHtml web part on this view but am unable to do so. The Traffice Light HTML I use is this:
=”•”
November 3, 2009 at 3:06 pm
Christophe
I recently came across a post that confirms that you cannot add a CEWP to a personal view. That would explain your issue. Here is the link:
http://servergrrl.blogspot.com/2009/10/content-editor-web-parts-standard.html
November 6, 2009 at 2:38 pm
Mike
Christophe, is there any way to apply colour coding in preview pane view to the column that is on the left (the one you hover over to display the preview). Can apply colours to any column in the right pane no problem.
November 6, 2009 at 2:51 pm
Christophe
I don’t think so. The left column displays the default Title field.
November 19, 2009 at 6:39 am
Fayadh
Hi Christophe,
Can u please take a look at my IF funtion is not working.
=”IF(“&[Availability Status]&”=”&”Available”&”, “&”Yes”&”)”
This will return just string,
IF(Available=Available, Yes)
Do you think this problem occurs from my Sharepoint Services 3.0 itself?
I dont know why but it seems all the functions aren’t working.
Regards,
Fayadh