SSRS 2005 - How to change default interactive sort from initially being ascending to descending?

  • The interactive sort feature seems to default to sorting the data in a given column in ascending order. Is there a way to change the default behavior so that it will sort data descending first? Having to double-click everytime a user needs to see data in descending order is tedious.

    Does anyone know if this is the same behavior in SSRS 2008?

    thanks in advance -- Pete

  • Multiply the expression for your interactive sort by negative 1

  • How do you do that with strings / dates?

  • Ninja's_RGR'us (5/13/2011)


    How do you do that with strings / dates?

    Good point -- what is the trick for strings/dates?

    (For numeric values, multiplying by -1 is indeed clever for the sort expression, though).

  • I think you can still multiply dates by a negative 1.

    Strings take a little more work . I would convert the first several digits to ASCII codes of the value to an integer.

    For example, assuming a case insensitive sort. This expression turns the first four characters into ASCII numbers, then concatenates them, then converts them to an INT and multiplies by negative 1. You would probably want to put in some additional code to handle words that fewer characters than you choose to sort by.

    =CINT(CSTR(ASC(UCASE(LEFT("ValueToSort",1))))

    + CSTR(ASC(UCASE(MID("ValueToSort",2,1))))

    + CSTR(ASC(UCASE(MID("ValueToSort",3,1))))

    + CSTR(ASC(UCASE(MID("ValueToSort",4,1))))) * -1

    PS. I am just vamping here. I threw this into a textbox to make sure the number was built correctly, but I haven't actually put this into an interactive sort expression. However, I don't see any reason why it wouldn't work. Let me know.

  • To answer the question about the 2008 version, yes, it's the same. The default is ascending and that can't be changed.

    The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking

  • I just tried multiplying a date by negative 1 and it didn't like it. So the longer answer is to convert the date to an INT in the format of YYYYMMDD and multiply by negative 1

  • Daniel Bowlin (5/13/2011)


    I just tried multiplying a date by negative 1 and it didn't like it. So the longer answer is to convert the date to an INT in the format of YYYYMMDD and multiply by negative 1

    Yup - I came up with the same conclusion as you -- convert the date to INT as YYYYMMDD in order to apply a neg 1.

    thanks

  • peterzeke (5/13/2011)


    Daniel Bowlin (5/13/2011)


    I just tried multiplying a date by negative 1 and it didn't like it. So the longer answer is to convert the date to an INT in the format of YYYYMMDD and multiply by negative 1

    Yup - I came up with the same conclusion as you -- convert the date to INT as YYYYMMDD in order to apply a neg 1.

    thanks

    I came up with an even easier way to do the descending date sort. Use this as your sort expression:

    =DATEDIFF("d",Fields!DateFieldToSortBy.Value,Today())

  • Daniel Bowlin (5/14/2011)

    I came up with an even easier way to do the descending date sort. Use this as your sort expression:

    =DATEDIFF("d",Fields!DateFieldToSortBy.Value,Today())

    Daniel -- way to keep "skinning the cat"! It intuitively makes more sense, too -- i.e., sort the dates according to the most recent date via datediff -- brilliant.

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply