Solved

Sorting in SSRS 2008 using mulitple parameters and depending on a sort by selection

Posted on 2015-01-02
4
61 Views
Last Modified: 2015-06-11
I have a report that has 8 sortby options.  I've pasted the sql code below.

ORDER BY R.CalloutLocation
	 , CASE WHEN @SortBy IN (1,4) THEN CalloutDate
			WHEN @SortBy IN (2,3) THEN R.CalloutReason
			WHEN @SortBy IN (5,6,7,8) THEN R.InstructorName
	   ELSE '0'
	   END ASC
	 , CASE WHEN @SortBy IN (1,3) THEN R.OffenderName
			WHEN @SortBy IN (2,5,8) THEN CalloutDate
			WHEN @SortBy IN (4,6,7) THEN R.CalloutReason
	   ELSE '0'
	   END ASC
	 , CASE WHEN @SortBy IN (3,6) THEN CalloutDate
			WHEN @SortBy IN (4,5,7) THEN R.OffenderName
			WHEN @SortBy = 8 THEN R.CalloutReason
	   ELSE '0'
	   END ASC	
	 , CASE WHEN @SortBy = 7 THEN CalloutDate
			WHEN @SortBy = 8 THEN R.OffenderName
	   ELSE '0' 
	   END ASC

Open in new window



However, when I run the report and select an option, it doesn't sort correctly.  I'd like to try doing the sorting in the report itself.  It currently only groups on the CalloutLocation.  Then there is a detail group below that.  Any help will be greatly appreciated.  Thanks
0
Comment
Question by:Sherry
  • 2
4 Comments
 

Author Comment

by:Sherry
ID: 40528313
Here's the rdl if that will help.
Offender-Attendance-Roster.rdl
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40528334
The syntax looks the same as what I have in the article SQL Server CASE Solutions (scroll down to 'A typical practice is to pass a parameter to a stored procedure that is the desired sort order'), other than I don't have the ELSE'0' so maybe that's not needed.

Just to check the box, are you certain @SortBy is one of the values in the IN blocks?
0
 

Author Comment

by:Sherry
ID: 40528366
I removed the else '0'  and it seems to be work fine now.  Now all I have to do is figure out why the formatting of the time isn't working like it should.  I have it set for military time HH:mm in the rdl.  The sql has it as

CONVERT(VARCHAR(10), C.StartDateTime, 101) AS CalloutDate

Yet, it still shows the seconds and I can't seem to get rid of it.  Thanks for your help.  I had a feeling it would be something simple.
0
 
LVL 14

Accepted Solution

by:
nishant joshi earned 500 total points
ID: 40560259
Looks like in report,You are using CalloutDateName instead of CallOutDate file from dataset.

Try to use "CalloutDate" Field.


Thanks,
Nishant
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

735 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