Another example of progress bar

In the interest of sharing, Peter Allen from California has sent me his own implementation of the progress bar for task lists.

I’d be surprised that his example exactly fits your needs, but the purpose here is to show that the method can be pushed far beyond the basic examples I used in my tutorial.

Peter takes into account three fields to build the progress bar: process status (choice), progress (choice) and % complete. Here is the formula:

="<DIV style='background-color:Beige;'><DIV style='background-color:"&IF(&#91;Process Status&#93;="0.Not Started","Gainsboro",IF(&#91;Process Status&#93;="1.Started",IF(Progress="3-Red","red",IF(Progress="2-Yellow","yellow","ADFF2F")),IF(&#91;Process Status&#93;="2.Completed","87CEEB","Black")))&"; width:"&IF(&#91;Process Status&#93;="1.Started",(&#91;% Complete&#93;*100),100)&"%;'></DIV></DIV>"

The legend at the bottom is plain HTML inserted in a separate Content Editor Web Part:

<SPAN class=style7><STRONG>Legend</STRONG></SPAN><SPAN class=style6>:&nbsp; <FONT style="BACKGROUND-COLOR: #c0c0c0">[&nbsp;&nbsp;&nbsp; ]</FONT> Not Started&nbsp; <FONT style="BACKGROUND-COLOR: #ccff66">[&nbsp;&nbsp;&nbsp; ]</FONT> On Track&nbsp; <FONT style="BACKGROUND-COLOR: #ffff99">[&nbsp;&nbsp;&nbsp; ]</FONT> Early warning of potential risk&nbsp; <FONT style="BACKGROUND-COLOR: #ff5050">[&nbsp;&nbsp;&nbsp; ]</FONT> Serious risk to completion&nbsp; <FONT style="BACKGROUND-COLOR: #99ccff">[&nbsp;&nbsp;&nbsp; ]</FONT> Completed&nbsp; <FONT style="BACKGROUND-COLOR: #000000">[&nbsp;&nbsp;&nbsp;&nbsp; ]</FONT> Excluded</SPAN>

Thanks for sharing Peter!

 

Update [09/30/2008]
Below a second version that displays the % complete value on the chart. Note the use of absolute positioning, so that the value doesn’t interfere with the bar. The formula is written for both Internet Explorer and Firefox.

The formula:

="<DIV style='position:relative; background-color:Beige;'><DIV style='background-color:"&IF(&#91;Process Status&#93;="0.Not Started","Gainsboro",IF(&#91;Process Status&#93;="1.Started",IF(Progress="3-Red","red",IF(Progress="2-Yellow","yellow","ADFF2F")),IF(&#91;Process Status&#93;="2.Completed","87CEEB","Black")))&"; width:"&IF(&#91;Process Status&#93;="1.Started",TEXT(&#91;% Complete&#93;,"0%"),TEXT(1,"0%"))&";'>&nbsp;</DIV><DIV style='position:absolute;top:0px;left:0px'>"&IF([Process Status]="1.Started",TEXT([% Complete],"0%"),"")&"</DIV></DIV>"

12 thoughts on “Another example of progress bar

  1. This is very cool!

    I was trying to adapt this to a list in which I have sales stages but no [% complete] field.

    My [Sales Stage] steps are:
    1-Contact made – Gainsboro
    2-Had meeting – Orange
    3-Delivered proposal – Yellow
    4-Sold – Green
    5-Try next year
    6-Do not solicit – Red

    I don’t need the legend though.

    Might you be able to piece together the formula for this?
    Thanks-
    Charlie

  2. Charlie, you first need a calculated column for the [Color]:
    = CHOOSE(LEFT([Sales stage],1),”Gainsboro”,”orange”,”…

    Then an HTML calculated column for the formatting:
    =””&[Sales stage]&””

    (you can of course combine both in one formula)

    I recommend that you take a look at other posts for more examples:
    https://pathtosharepoint.wordpress.com/category/the-html-calculated-column/
    Actually your need is very close to the post about color coding.

  3. Pingback: Printable progress bars « Path to SharePoint

  4. I am new to sharepoint UI.

    1) Unable to find your TextToHTML-v2.1.1.txt.

    2) Where I need to copy this file and where I need to refer. Please be more specific

  5. How can I add background image instead of background color

    point 1) How can I adjust my image width depend on a value

  6. Hey Peter

    I have a doubt as to where in exactly in the code to use this formula because i have used databound as my data is being from the datasource.

    Can you please help me on this?

  7. Christophe,

    I’m having trouble putting text into the progress bar. I started with your Progress Bar 2 example, and only changed the background color from red to beige. All worked well.

    I then examined the example above and added the text line between the last two tags. Here’s the code I inserted:

    “&TEXT([% Complete],”0%”)&”

    The column has the correct number for % Complete in the HTML, but no text is displayed.

    Here’s the complete formula for the column:
    =” “&TEXT([% Complete],”0%”)&””

    Any assistance would be greatly appreciated.
    Thanks,
    Neal

  8. I have tried using the above code, but get the following error message:
    The formula contains a syntax error or is not supported.

    Additionally, I would like to add on a couple of “process status” options as we use: Not started, In progress, Completed, On hold, Pending input, Cancelled but am keeping that attempt on hold until I get the original formula right :s

    The formula I am using now is: =” “&IF([Task Status]=”1.Started”,TEXT([% Complete],”0%”),””)&””

    Any idea what could be wrong?

    Thanks in advance & best regards,

    Vivian

Comments are closed.