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
Solved

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

Posted on 2015-01-02
4
60 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

856 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