strange sorting in SQL Reporting Services 2008

Posted on 2011-05-02
Last Modified: 2012-06-27

I have a group sort in SQL Reporitng Services 2008 based on a column's if, then statement (iif function).  The iif function produces a numeric value of 1, 2, 3, etc.

The report is not being sorted by "1, 2, 3, etc." but, by "1, 10, 11, 12....2, 3, 4, etc.".

How do I get it to sort in the correct numeric order of 1, 2, 3, 4, 5, 6, etc.

You see, the report is taking the sort way too literally.  It is sorting 10 before 2.


Question by:apitech
    LVL 22

    Accepted Solution

    Then your iif function probably returns the values as text for example:
    and not as a number. Replacing
    might solve your problem.
    LVL 1

    Author Comment

    Hi Nicobo:

    YOU DID IT, AGAIN!  Thank you!  That was it!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This code started out as a fix for a customer that had incoming data that was hunderds of numbers and words long that was to fit in one column. The problem was that the customer did not want to split words or numbers when wrapping in the column. …
    A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. (htt…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now