locked
HTML Calculated Column Formula RRS feed

  • Question

  • I'm trying to use a HTML calculated column so that I can display a RAG status bar for my tasks in SharePoint. I had it working until I added the IF containing % complete. Can you tell me where I'm going wrong please?

    Understand there is a < missing infront of the DIV Style in the first and last lines - only way I could get it to display:

    ="DIV style='width:100%;background-color:"&IF(Slippage>30,"red",IF(AND(Slippage>=-7,Slippage<=-29),"orange",IF(AND(Slippage>=-7,Slippage<=29),"orange",IF(Slippage<7,"green","green",IF(% Complete=100,"blue","blue")))))&";'>/DIV>"

    Thanks - Rob

    Thursday, December 2, 2010 1:13 AM

Answers

  • I'm pretty sure this is not possible with a calculated column, but its really easy to do with SharePoint Designer. Here is a simple example that I did just by right clicking the xsltlistviewwebpart in SharePoint Deisgner, picking Add -> Column, and then inserting some xsl logic

     

    <xsl:if test="@Title='0'">
    <div style="color:red">BAD</div>
    </xsl:if>
    <xsl:if test="@Title='1'">
    <div style="color:yellow">OK</div>
    </xsl:if>
    <xsl:if test="@Title='2'">
    <div style="color:green">GOOD</div>
    </xsl:if>

    here is a video of me doing this

    http://wqjnzq.blu.livefilestore.com/y1pO_dxPEwwSkZFDlkRhG63vXK6PZBGAnAxTKmgEakRBX_MAHs014k1BEtvJnVMSX8XJXUQ_d9uwXn1wZ1SbcVMe6aWQZOLvxSA/XSLTCalculatedColumn.wmv?download&psid=1

    • Marked as answer by GuYuming Wednesday, December 8, 2010 5:41 AM
    Thursday, December 2, 2010 5:48 AM

All replies

  • I'm pretty sure this is not possible with a calculated column, but its really easy to do with SharePoint Designer. Here is a simple example that I did just by right clicking the xsltlistviewwebpart in SharePoint Deisgner, picking Add -> Column, and then inserting some xsl logic

     

    <xsl:if test="@Title='0'">
    <div style="color:red">BAD</div>
    </xsl:if>
    <xsl:if test="@Title='1'">
    <div style="color:yellow">OK</div>
    </xsl:if>
    <xsl:if test="@Title='2'">
    <div style="color:green">GOOD</div>
    </xsl:if>

    here is a video of me doing this

    http://wqjnzq.blu.livefilestore.com/y1pO_dxPEwwSkZFDlkRhG63vXK6PZBGAnAxTKmgEakRBX_MAHs014k1BEtvJnVMSX8XJXUQ_d9uwXn1wZ1SbcVMe6aWQZOLvxSA/XSLTCalculatedColumn.wmv?download&psid=1

    • Marked as answer by GuYuming Wednesday, December 8, 2010 5:41 AM
    Thursday, December 2, 2010 5:48 AM
  • This is a cross-post of a question on SPSE:

    HTML Calculated Column Formula

    Dribbel's answer there fixes the formula, which I believe is being rendered using Christophe's Text to HTML script:

    The HTML Calculated Column

    Thursday, January 12, 2012 5:55 PM