Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Minimum formula Post Reply Post New Topic
Author Message
PeterH
Newbie
Newbie


Joined: 13 Dec 2012
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote PeterH Replybullet Topic: Minimum formula
     Posted: 13 Dec 2012 at 4:26am
Hi, new to the forum today and am hoping someone can shed some light on a problem I'm having with the 'minimum' and 'maximum' functions.
 
I have a database of >20 million records, containing serial numbers of products, in batches of 50,000 in each batch. Sets of these serial numbers are allocated to users (user is a numeric field) and when they are allocated a datetime field records that allocation date/time.
 
I'm trying to report the start and end serial numbers allocated to a user on each day (there could be multiple allocations to multiple uses on any given day) so I'm grouping the allocation date field by 'second'.
 
I need to show the min and max serial numbers allocated to a user on a given day and using minimum({serial_no},{allocation_date}) and maximum({serial_no},{allocation_date})  for this. So far so good -
 
My problem is, if in a batch of 50,000 serial number records the first 5000 are allocated to user 1 and the next 4000 to user 2, followed by the next 3000 to user 1 again (all on the same day) the report shows that user 2 has 4000 (correctly) but user 1 is shown as having 12,000, i.e. the report is ignoring the allocation to user 2 in the middle.
 
Hopefully I've explained my query clearly  - if anyone can offer me some clues as to how I can show these allocations correctly I'd be very grateful
 
Thanks
 
PeterH
IP IP Logged
comatt1
Senior Member
Senior Member
Avatar

Joined: 19 May 2011
Online Status: Offline
Posts: 337
Quote comatt1 Replybullet Posted: 13 Dec 2012 at 8:14am
Are you trying to subtract max-min?

Are you grouping by user (this should be yes, if you want the below running total to work)

If this were my report, and I wanted just a count I would create running totals, do a count, and evaluate by userid. That is if I am understanding your report correct?

So the RT would go like

Summary Field -> {serial}
Summary -> Count


Evaluate
Formula
{userid}={group name}


Reset
On change of group, userid

Edited by comatt1 - 13 Dec 2012 at 8:18am
IP IP Logged
PeterH
Newbie
Newbie


Joined: 13 Dec 2012
Location: United Kingdom
Online Status: Offline
Posts: 5
Quote PeterH Replybullet Posted: 14 Dec 2012 at 12:48am
Thanks for your response
 
The report is grouping by user, then stock type then allocation date, then batch_No
 
It works perfectly when the allocations are all done on the same day but if, in the example above (12000 serial numbers), the first 5000 and last 3000 are allocated to user 1 on day 1 and the 4000 in the middle of the serial number range are allocated to user 2 on day 2 I get the problem where the report shows user 1 having all 12000 incorrectly allocated to him (on day 1) when I try and calculate the start and end serial number of the allocated ranges using minimum and maximum formulae,  but user 2 is shown as having the middle 4000 correctly allocated to him on day 2.
 
What I want to report is:
 
User 1-   Start Serial 0001       End Serial 5000     Qty 5000  Date 12/12/12
User 1-   Start Serial 9001       End serial 12000    Qty 3000  Date 12/12/12
 
User 2-   Start Serial 5001       End Serial 9000     Qty  4000 Date  13/12/12
 
 
What I currently end up with is:
 
User 1- Start Serial 0001 End Serial 12000 Qty 12000 Date 12/12/12
 
User 2- Start Serial 5001 End Serial 9000 Qty 4000 Date 13/12/12
 
which implies that user 1 got all 12000 serials, which he didn't
 
Hope that helps explain what I'm trying to achieve a bit more, any further suggestions would be appreciated
 
Thanks
PeterH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum