Solved

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

Posted on 2015-01-02
4
63 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

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

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

626 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