Avatar of jspc
jspc
Flag for Australia asked on

Crystal Report Sorting/Grouping

Hello,

Can you please help me with the sorting/grouping of this Crystal Report file?

I have a crystal report; purchase order file.
The original entry of the data was in the order of product code 1003, 1006, 1005. (Screen shot attached, EntryInDatabaseOrderExample)
When you view the Purchase Order in CR PDF the order of product code 1005, 1006, 1003 (PDF Attached)

I can’t figure out why the order in the crystal file isn’t in the same order as how it was entered into the database.

Attached is the file saved with data. Look at PO Number PO00136.

Thank you.
EntryInDatabaseOrderExample.png
StructuredPurchaseOrder.pdf
StructuredPurchaseOrder.rpt
Crystal Reports

Avatar of undefined
Last Comment
James0628

8/22/2022 - Mon
Mike McCracken

YOur report has 2 groups
Group 1 - Document Number
Group 2 - Formula - Structured Group
                        totext({TRANSDETAILS.ZStrStkItemView})  + totext({TRANSDETAILS.ForeignUnitPrice})

Groups serve as sorting fields so your report is sorted by Document Number then within each Document Number group the records are sorted by the Structured Group formula

If you want it sorted by the Product code you need to
1.  Group on the product code rather than the Structured Group
2.  You can try to convert the productCode to a number - Val({ProductCode})
      Insert in in the detail section
      Right click it
      Click INSERT --> SUMMARY
      Set Summary to SUM
       Insert it in the GF2
      Click REPORT --> GROUP SORT EXPERT
       Change None to ALL
      Select the Sum of ProductCodeValue as the sort field

mlmcc
jspc

ASKER
No, not by Product Code, it needs to be sorted by how it was entered into the database. (Order entry)

Also I cannot convert Product Code to a number as this field contains both numbers and alpha.
ASKER CERTIFIED SOLUTION
Mike McCracken

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
James0628

You have a LineNumber field.  If that reflects the order in which the items were added, then you would theoretically want to sort by that before your StructuredGroup formula (eg. add a group on LineNumber and put it above the group on StructuredGroup).  However, when I tried that, it seemed to change the output on your report pretty drastically, so I suspect that that isn't the answer in this case.

 James
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23