on 04-20-2020 8:48 PM
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.
Ok here's what you need to do:
1. Insert a Group on the Machine field
2. Create a formula called @sort with this code:
SELECT {Fault_field} //replace this with the database field or formula field that displays Fault strings
CASE 'severe' : 1
CASE 'significant' : 2
CASE 'insignificant' : 3
DEFAULT: 4
3. Go to the Insert Summary option > Choose the @sort field to aggregate on and set its aggregation function as "Minimum"
4. Suppress the summary field that CR places on the Group Footer
5. Go to the Group Sort Expert > Select Machine Group as the group to sort ALL and sort it based on the @sort summary field in Ascending order.
-Abhilash
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.