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?
You can achieve this by following below steps:
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.
- 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:
- 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(
- 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.