cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Crystal Reports - Conditional record sorting

Former Member
0 Likes
1,554

I'm attempting to sort report records based on multiple fields, but not as simple as Field A - ascending, Field B - descending, etc. My records have fields "machine", "fault", "magnitude", and "date". Machines are given a fault at a certain magnitude on a certain date. I want to sort based first on "magnitude" (descending) and then "machine"' (ascending), "fault" (ascending), and then "date" (ascending). However, the kicker is that a "machine" may have more than one "fault" and possibly assigned a different "magnitude". I want all "faults" assigned to the same "machine" to be sorted one after the other, even if the "faults" are different "magnitudes"

For example, Machine A has a fault assigned Significant. Machine B has two faults: Severe and Insignificant. Machine C has a fault assigned Severe. Machine D has a fault assigned Insignificant. Machine E has two faults both assigned Significant.

The correct order would be:

Machine B - severe

Machine B - insignificant

Machine C - severe

Machine A - significant

Machine E - significant 1

Machine E - significant 2

Machine D - insignificant

Essentially, I want the records to be supported based on "magnitude" but with "faults" regardless of "magnitudes" for identical "machines" to be kept together.

View Entire Topic
DellSC
Active Contributor
0 Likes

The only way I can think of to do this would be to use a Command (SQL Select statement). How good are you SQL skills? If you would like some help building the query, please go to the Database menu and then "Show SQL Query...", copy the query and paste it here. Also, please let me know what type of database you're connecting to.

For more information about working with Commands, see the blog here: https://blogs.sap.com/2015/04/01/best-practices-when-using-commands-with-crystal-reports/

-Dell