2

Here's a variation I'm having an issue with: I'm trying to populate a column based on the content of another column (choice field). While I'm currently doing this with a workflow, I know it can be done with a calculated column, too. What I want to do is populate this column with a JPG located in the image library of the site based on the choice column. I can't figure out how to bring up the image. (I'm currently trying to make this visible in a view other than the default view, if that makes any difference) Any ideas?

4
  • How many choices you have in your column? Commented Feb 20, 2020 at 5:24
  • There are three choices
    – DanJ
    Commented Feb 20, 2020 at 16:03
  • Try the below solution. As you have three choices you need to use nested IF one more time. Commented Feb 20, 2020 at 16:06
  • I changed the Calculation to reflect my list. However, the CSR is proving to be a bit more troublesome - see below.
    – DanJ
    Commented Feb 20, 2020 at 17:59

1 Answer 1

1

You can achieve this by following below steps:

  1. Create Calculated column:

    use formula like below:

=IF([ChoiceField]="Choice1", "https://siteUrl/PicLibrary/Image1.extension", "https://siteUrl/PicLibrary/OtherImage.extension")

For multiple conditions you can use Nested IF:

=IF([ChoiceField]="Choice1", "https://siteUrl/PicLibrary/Image1.extension", IF([ChoiceField]="Choice2", "https://siteUrl/PicLibrary/Image2.extension", "https://siteUrl/PicLibrary/OtherImage.extension"))

This will give you the Image URL.

  1. Use Client Side Rendering (CSR) to show the Image in list View:

You can use Client Side Rendering (CSR) to customize your list view and show the image in view using the image URL you got from above step.

Check below article for more explanation an some of the sample examples:

SharePoint 2013 Client Side Rendering: List Views.

Note:

  1. Sometimes comma(,) does not work in formula (I am not sure but it is based on something language or regional settings on your site). So in that case use semicolon(;) instead of comma(,).
  2. Using HTML Markup in Calculated field is not supported by Microsoft (Article). So, it is better you should use CSR to render the image in list view.
2
  • Thanks - the calculated column makes perfect sense. However, I'm unsure about the CSR JS that I should use in order to make the images appear (instead of the URL for the image). Can you provide clarification?
    – DanJ
    Commented Feb 20, 2020 at 17:29
  • Using calculated column you will just get the URL of images. So, in order to show the images you need to do something extra. And as you are using SP 2013, best way for you is to change the list view rendering using CSR to convert image links into actual image. Commented Feb 21, 2020 at 2:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.