Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group sorting problem

Status
Not open for further replies.

Bontebok

Programmer
Nov 18, 2002
63
US

Hi All,

I am having trouble coming up with a way to group detail rows together and sort those groups based on the value from one row in the detail records.

Example:

Code:
order   z_row    timefrom  showtime
-----------------------------------
    1       1       10:15      NULL
    1       2        NULL     11:30
    2       1       10:00      NULL
    2       2        NULL     11:30
    3       1        1:00      NULL

Each row represents a detail to an order item record. The database is a multivalue universe database, so all key associations are made by a key and a row id.

I need to group all order detail items and sort based on the timefrom which comes from one row in the order details.

Example output:

Code:
order   timefrom  showtime
--------------------------
    2      10:00     11:30
    1      10:15     11:30
    3       1:00     (none)

Any ideas?

Note: Using Crystal 8.0.

Thanks,
Jeremy
 
In 8.5, I'd have done this using an 'Alias' to add the data twice, once with null time-start excluded. Group by Order, but TimeFrom (alias table) will be usable as a higher-order group.

I'm not certain this will work in 8.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
You could probably manage this by using a formula instead of {table.showtime}:

if next({table.order}) = {table.order} then totext(next({table.showtime}),"hh:mm") else "None"

Then place your fields in the group header along with this formula and suppress the detail field.

-LB
 
Hi Madawc and lbass, thanks for the replies.

Madawc, I could not understand how to exclude the null time-start (timefrom?) in your statement.

lbass, interesting solution but unfortunately, the position of the data and number of line items varies from 1 to 4 and the important row is not guaranteed to in the next row.

I was able to find a solution on my own, this involved creating formula called FirstTimeFrom, which contained a Global shared variable that sets the time based on the important row that contains the timefrom value WhileReadingRecords.

I was then able to sort all records in the exact order with the timefrom row being first and grouping by the FirstTimeFrom field and it re-grouped/ordered the other groups by the timefrom.

I don't exactly know how it's working like this, but it is. I also want to note that I could not get the multivalue database to sort by certain fields, so I moved all groups and sorts to formulas so that Crystal would need to sort all data internally before generating the report.

Jeremy
 
The test would be
Code:
not isnull({Your.Date})

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top