Skip to Content

Crystal-Reports (2008)-Sorting For Case Sensitive Data

Crystal Reports is not case sensitive in nature.

If we have a business requirement of sorting the data which is case sensitive, then we would be required to do the following actions.

Test Scenario

We have a database field Employee with data values as

Employee Name

Ashish

ravi

ashish

Ravi

In general, when we drag the Employee Field at the detail section the output generated would be something like below, which will have same default sort order as that of database level

Employee Name

Ashish

ravi

ashish

Ravi

In order to have a customized sorting working for the above scenario, we would be required to do the following actions

1)      Go to the Field Explorer and create a new formula say fr_Sorting_Order with the below code  

 

AscW ({DB.Employee Name})

 

Here Ascw is a built-in function, which takes the input as any Database field value, which is of string in nature and returns the corresponding unicode value for the first character of the input string.

({DB.Employee Name})-It is the Database field which is of string data type.

 

2)      Once we are done with creating the formula fr_Sorting_Order. Go to the Group Expert and create a new Group on the newly created Formula.

3)      Set the sorting order as desired (Ascending, Descending…) at the Group level.

4)      Now, go to the Section Expert and suppress the Group Header and Footer.

5)      The Final output generated will be as shown below

 

A) In case if we have set the Sorting Order as Ascending at the Group Level

 

                Employee Name

Ashish

Ravi

ashish

ravi

 

B) In case if we have set the Sorting Order as Descending at the Group Level

 

                Employee Name

ravi

ashish

Ravi

Ashish

Note: – In case, we want to have the Group Value to be displayed at the Report Level we need to follow the below steps

1)      Don’t suppress the Group Header and Footer

2)      Place the Group Field at the Group Header.

3)      Right Click on the Group Field and select Format Field Option.

4)      In the Format Field, select the Common Tab and go to the Display String Property and set the value as ({DB.Employee Name}) which is the Data base field value.

5)      We can also set this value at the Group Expert Level for the Group 1, which we have created by going to the option Tab and selecting the new option Tab from the Group Change Options window.

6)    Finally, we would be required to check the Customize Group Name Field Check Box and select the value which we need to display as Customize Group Name.

To report this post you need to login first.

1 Comment

You must be Logged on to comment or reply to a post.

Leave a Reply