Rob's TIMSS Blog

My discoveries and ramblings of TIMSS/Personify.

Monday, May 14, 2007

Crystal Reports: Sorting Parameter

I have a couple Crystal reports that I've added a parameter to that allows the report to be sorted different ways. For example, our meeting function sheets can either be sorted by room or by date. To do this in the same report, I created a parameter called SortBy that is either DATE or ROOM (see Online Report Parameter Pick List to see how to pick parameters for your online report).

Then I added a formula field to the report that creates a value to sort on based on the parameter value:

If {?SortBy}='DATE' then ToText({Command.start_date})
else
If {?SortBy}='ROOM' then ToText({Command.facility_room_id})


and I use this value to sort my report.

I've done something similar with my committee roster. One group wants their committee sorted one way, and the rest a different way. So I created a parameter and a formula that generates the value to sort by:

if {?Format}='NORMAL' then
if ({COM_COMMITTEE_MEMBER.VOTING_STATUS_CODE}= 'NON_VOTING' and {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'STAFF') then 99 else
if {COM_COMMITTEE_MEMBER.VOTING_STATUS_CODE}= 'NON_VOTING' then 11 else
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'CHAIR' then 1 else
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'VCHAIR' then 2 else
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'SEC' then 3 else
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'TREAS' then 4 else
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'EXOFF' then 5 else
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'MEMBER' then 10
else 9
else if {?Format}='CFLT' then
if {COM_COMMITTEE_MEMBER.POSITION_CODE}= 'CHAIR' then 1 else 9

Thanks to Edward B. for the hint at TAUG.

Applies to: TIMSS6 & Personify

0 Comments:

Post a Comment

<< Home