Often you will get a requirement like this:
Create a calculated column which concatenate the url text with an existing column value.
This seems to be an easy task, except one thing: SharePoint doest not render hyperlink in calculated column by default.
For example, I have a list with 2 columns: Search term and Google Search. Google Search is a calculated column with this formula
Now, this is what I will get by default:
There are a few ways to fix this problem. Usually people will recommend you to create a Hyperlink column instead and create a workflow to update the Hyperlink value (http://social.technet.microsoft.com/Forums/ar/sharepoint2010customization/thread/32d32e47-3256-4806-8775-c250b6243038) . Or, you can place a script on the page that loop through the HTML nodes and replace the unfriendly html tags with a hyperlink as described here http://practicalsharepoint.blogspot.com/2011/10/dynamic-hyperlinks-in-calculated.html.
But today, I’m going to show you how to trick SharePoint into displaying the hyperlink, and it is going to be very easy.
1. Modify the calculated column and change the returned data type from Single line of text to Number/Currency/Date and Times. Click OK.
2. Go back to the list and be amazed ๐
This will also work when you’d like to achieve the same thing with the image tag <img>.
Loving it.
Great workaround.
Great! but this works in SharePoint 2010, but it does not work in Sharepoint 2007! any views..
I tried this multiple times and with the img tag… and it didn’t work.
Thought this was the answer I wanted. However, if you use the ListViewByQuery Webpart, it displays the value as text again. ๐ฆ
HI,
How can you achieve filtering on this calculated column?
This didn’t work for me with SharePoint 2010, is it a 2007 thing only?
Don’t work in Sharepoint 2007 ๐ฆ
Awesome!
Hi, works well to display in list view, does not display in form view for some reason.
I am pulling a list of like-records into a repeat table in new form to allow the user to see other, possibly related records. The ‘URL’ column that shows a good hyperlink in the list using your formula approach, bit it does only show a blank space in the form. Any idea why, or a solution perhaps?
Thank you.
Stefan
Search term doenot replaced! What i am doing wrong? Same code
This is exactly what I was attempting to do in a Document Library. I used the Document ID link to set up the link. =”Click Here
Awesome, thanks
Pingback: How to set up Red-Yellow-Green status indicators in a task list without any customizations « sharepointyoda
Hah! That’s pretty cool. EXACTLY what I was looking for.
Thank you! This worked perfectly!
You rock! Thank you so much for posting this!!
hey thank you very much. good workaroung
While it is great that there is some way to make this work, And it does for me in 2010. it drives me crazy that you have to do stupid things like this in sharepoint (A LOT). I have been a software dev nearly 30 yrs now and I would be embarrased to put out a product that required such lameness to accomplish a fairly common thing. Why on earth does it even allow you to put a concatenated string into a numeric datatype?
This worked wonderfully for me (SharePoint 2010).
I discovered a partial workaround for the column alignment issue caused by applying the Number data type (which makes the calculated column right-aligned, leaving a huge white space appear to the immediate left – as shown in your screenshot). If you modify the View Style to “Newsletter, no lines”, the column data will be left aligned (only the column title will be right aligned). That also places the calculated column closer to any preceding columns. This view style is available in both lists and libraries. Another useful View Style option if you are on a list is “Boxed, no labels”.
Another note: One needs to be very careful with calculated column syntax – that might be responsible for the problems some have noted in previous comments. There’s a useful reference page about using Calculated Field Formulas on the MSDN site at http://msdn.microsoft.com/en-us/library/bb862071(office.14).aspx
doesnt work in SP2007… although this solution did the trick: http://practicalsharepoint.blogspot.co.il/2011/10/dynamic-hyperlinks-in-calculated.html
๐
Works!!!!
Great work
Thank you
Thanks a lot, also works in Sharepoint 2013.
Thanks! This is exactly what I was looking for and worked perfectly.
Reblogged this on My Windows System Administrator and commented:
This post provides an excellent work around for calculating hyperlinks in SharePoint 2010. It definitely came in handy with a recent project I was working on.
Handy tip. Agree with Mike J. I also like the alignment tip from Tod Beane. The header alighment can be fixed up in SHarePoint Designer.
You totally rock! This is the hack of all time.
Exactly the solution that I need!
Brilliant!
THANK YOU! Worked great in SP2010 Foundation
you can wrap your formula with a css-styled DIV to overcome the alignment: =””&Your formula starts and ends between the ampersands&””
oops – it swallowed the html
This only works in a listview for me. When I use the detail view for an element it’s text again.
Reblogged this on Share Point Online and commented:
Really simple and fast workaround
thanks !!!!!!
Hi, I’m using this solution, but I have a problem to calculate the hyperlink by using a https Link & the column ID. It happens that the ID disapear some times. does anybody have a solution for this? Thanks!
Thank you very very much!
Thanks!!!! you rules ๐