Sorting results by colume
Using Report Server 2005 I have created a report that displays the results of one field for example "Rooms" as colume headers and time vertically on the left;
1 10 11 12 2 3
4 5 lib Int
7:00
7:30
8:00
The result above as you can see is not sorted right. How can I sort it to ascend in order? like so;
1 2 3 4 5 6 7 8......12 lib
Int
7:00
7:30
8:00
Thanks
November 23rd, 2010 3:20pm
you need to put sort expression in column groping property,
here you have Rm number in String thats the reason sorting in this way,
do you have any key column for Rm# , like we do when we have to sort month we take desc as filed expression and MonthKey as sort expression.
Gaurav Gupta http://sqlservermsbiblog.blogspot.com/
Free Windows Admin Tool Kit Click here and download it now
November 23rd, 2010 3:34pm
Hi,
Please try the below
1. Right click and open column group properties that you have for room numbers
2. Click on the sort tab
3. Click add button
4. Click on the expression button and enter below and click ok.
=IIF(isnumeric(Fields!RoomNo.Value),LEFT("000",3-LEN(Fields!RoomNo.Value)) & Fields!RoomNo.Value,Fields!RoomNo.Value)
Note : Above expression assumes that your room number does not exceed 3 digits. If it does you may have to add extra 0 in "000" and alter number 3 to the number of zeros.
5. click ok and close group properties
Hope this helpsPlease click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.
BH
November 24th, 2010 2:54am
Instead of the above expression, I think it would be better and simpler to use
=cint(Fields!RoomNo.Value)
Netjet, your results are getting sorted but it is treating the field like a string. Hence 1,10,11 will come before 2. If you convert it into an integer like I have written in the expression and then use it in the sort expression, it should be fine.Cheers,
Jason
P.S. : Please click the 'Mark as Answer' button if a post solves your problem! :)
Free Windows Admin Tool Kit Click here and download it now
November 24th, 2010 6:24am
Hi Jason,
I tested cint(Fields!RoomNo.Value). It works when the value is numeric. As per the layout given by user, he has values
lib int for room numbers as well. When string values are passed, the cint fails with an error. Please correct me if I am wrong in this.
Regards
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful.
BH
November 26th, 2010 1:02am
Oh sorry Bilal, I overlooked that part, my bad... In that case, your answer is the right one. The one I gave with cint would throw up an error as you rightly said.Cheers,
Jason
P.S. : Please click the 'Mark as Answer' button if a post solves your problem! :)
Free Windows Admin Tool Kit Click here and download it now
November 26th, 2010 3:01am