locked
Display image in Calculated Column RRS feed

  • Question

  • Hello,

    I'm trying to display an image in column B, if column A = greater than NULL. 

    I tried using this formula in a Calculated column, and then using content editor to convert the HTML DIV tag, but no luck: 

    =IF(Comments="1","<DIV><img src=http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/red_flag.jpeg></DIV>",IF(Comments="0","<DIV><img src=http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/flag_3_right_blue_2_256.png></DIV>"))

    Any ideas?

    Thursday, July 14, 2016 12:38 AM

Answers

  • Hi DanielMAcclario,

    Per Sathiya's suggestion, I have done a test in my SharePoint 2013.

    For your requirement, create calculated column "column B" with the Formula:

    =IF([column A]="1","<img src='http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/red_flag.jpeg'>","<img src='http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/flag_3_right_blue_2_256.png'>")

    Note: choose Number.

    =IF([column A]="1", make sure there is double quotation marks on 1.

    Besides, You can use the following Formula:

    ="<DIV><img src='"&IF([column A="1","http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/red_flag.jpeg","http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/flag_3_right_blue_2_256.png")&"'></DIV>"

    Note: also choose Number.

    Best Regards,

    Lisa Chen


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.




    Friday, July 15, 2016 6:11 AM

All replies

  • Hi Daniel,

    If you have only two values in column A(0 an 1), you can go with the below formula in calculated column:

    =IF(ColA>0,"<img src='https://....../SiteAssets/images/paper.png'","<img src='https://....../SiteAssets/images/beige.png'")

    Make sure that the data type returned from the formula is Number as highlighted below


    Regards, Sathiya

    Thursday, July 14, 2016 9:17 AM
  • Thanks for the reply. I gave this a go, however, I'm faced with the same issue as with the DIV.

    Instead of displaying the image, the column just displays "img src='http://xxxxx.xxxx.xxx.SiteAssets/flad_3_right_blue_2.png'


    Friday, July 15, 2016 2:28 AM
  • Hi DanielMAcclario,

    Per Sathiya's suggestion, I have done a test in my SharePoint 2013.

    For your requirement, create calculated column "column B" with the Formula:

    =IF([column A]="1","<img src='http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/red_flag.jpeg'>","<img src='http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/flag_3_right_blue_2_256.png'>")

    Note: choose Number.

    =IF([column A]="1", make sure there is double quotation marks on 1.

    Besides, You can use the following Formula:

    ="<DIV><img src='"&IF([column A="1","http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/red_flag.jpeg","http://xxxxx.xxxxxx.local/DanielTraining/SiteAssets/flag_3_right_blue_2_256.png")&"'></DIV>"

    Note: also choose Number.

    Best Regards,

    Lisa Chen


    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.




    Friday, July 15, 2016 6:11 AM
  • That's really great. Thanks!
    Sunday, July 17, 2016 11:33 PM
  • In SharePoint 2013, is there any way to use text instead of a number?  When we use a number, we cannot get the document library in SharePoint Workspace.

    In SharePoint 2010, we used SharePoint Designer to added the tag disable-output-escaping=”yes” to the <xsl:value-of> tag

    https://blogs.technet.microsoft.com/jay/2013/06/17/how-to-display-images-in-a-calculated-column-of-a-sharepoint-list/

    but when we upgraded to SharePoint 2013, this caused users not to be able to select the checkboxes next to the documents.

    How can we add the tag disable-output-escaping=”yes” to the <xsl:value-of> tag in SharePoint 2013 as there no longer is a Design view


    Wednesday, September 28, 2016 2:56 PM