Monday, November 28, 2011

Crystal Reports : Using a specific Group Sort Order

This is an oldy but a goody;

When Inserting a Group in a Crystal Report, the report then becomes automatically sorted by the highest level Group. This is usually no big deal, but sometimes, you just want a little control over "what comes first", by which I mean "what is printed on the first page".

Let us consider my father's management report for Hill's Heating. In his accounting software, Hill's Heating appears as a normal company alongside customers, so it would always appear on the sixth or seventh page of the Report, alongside the rest of the "H's".

So what I did was instead of Sorting the report on {CONTACT.NAME}, I created a Group on it instead. Then went into my Group Expert (Report | Change Group Expert from the top level menu) to enable the Specified Sort Order under Options. You'll be able to select it from the "in ascending order" drop down list.

Once you select Specified Order, the "Specified Order" tab becomes available. Here you can explicitly add the values you'd like to appear first in your "sorted" list (by selecting the items from the "Named Group" drop down list).

You will also NEED to go into the "Others" tab and select "Leave in their own Groups", otherwise any Group not defined the in the Specified Order is resigned to this "Others" category.

This way, I could force Hill's Heating to the top of my report, then resume normal sorting after that first entry was out of the way. Try it.