Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have an issue and I cannot find any documentation on it. I have a XsltListViewWebpart with a column called Dates that contains a few years in each row. Currently they appear as:

  • 2008
  • 2009
  • 2010
  • 2011

I would like them to appear in descending order. I understand this is just text and I need to tell Sharepoint somehow that the row contains years, only then can they be sorted in a descending order. I have tried to mess with the row formatting in order to achieve this but to no successful result.

If its in anyway relevant, the years in each row are also links to the respective folders. How can I achieve this in Sharepoint Designer?

Thank you for any suggestion. Please let me know if I didnt explain the issue correctly.

If there is any documentation on this please give me a link. Thank you.

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

The most obvious way for me would be to convert the column to type Number (List Settings -> click on the column name -> change type from "Single line of text" to "Number", then click "OK"), and then sort it in descending order (just modify sorting settings of the view).

If you're trying to achieve this by using XSLT, then it seems you're looking for the XPath number function.

Usage example:

<xsl:value-of select="number(@Year)" />

Another example:

<xsl:for-each select="/dsQueryResponse/Rows/Row">
  <xsl:sort select="number(@Year)" order="descending" />

  <!-- ... -->

</xsl:for-each>
share|improve this answer
add comment

If the column is a text column, you can still just sort descending. There's an option on the Sort button on the ribbon to change the sort settings. There's no need to convert at all, unless I'm missing something.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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