1

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.

4

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>
0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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