Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Display 3 records before and 3 records after Value

Posted on 2015-02-04
18
Medium Priority
?
42 Views
Last Modified: 2015-02-20
Hi Experts

We have a data base that contains a route id, drop sequence, truck id and if it participates in our program (yes or no).  What we would like is to get a report that would show us the truck, the participants (those marked "YES") and the 3 stops (using drop sequence) before the record and 3 after so we would end up with 7 records total for each group.

Any help would be greatly appreciated.
0
Comment
Question by:spudmcc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 9
18 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 40589229
Are you doing any other summarization in the report?

Is your data like
Route    Drop   Truck  Participant
 111         1          A1         Y
 111         2          A1         Y
 111         3          A1         Y
 111         4          A1         Y
 111         5          A1         Y

Or can the participant value change?

Can you provide some sample data?

mlmcc
0
 

Author Comment

by:spudmcc
ID: 40589239
Here is a simple sample of the data we are using.  Pretty much just what you used in your example.

A
EXAMPLE.xlsx
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40589275
So for the given data the first record is line 164 with a ys you want to see

BN1168      BX31      3390      NO
BN1169      BX41      990      NO
BN1187      BX41      1550      NO
BN1188      BX71      920      YES
BN1194      BX61      1760      NO
BN1196      BX61      1740      NO
BN1198      BX61      980      NO

If you have several YES in a row do you want to see the first 3 after the last YES?

BN1168      BX31      3390      NO
BN1169      BX41      990      NO
BN1187      BX41      1550      NO
BN1188      BX71      920      YES
BN1189      BX71      923      YES
BN1194      BX61      1760      NO
BN1196      BX61      1740      NO
BN1198      BX61      980      NO

What about the case of a YES in the 3 following records?

BN1168      BX31      3390      NO
BN1169      BX41      990      NO
BN1187      BX41      1550      NO
BN1188      BX71      920      YES
BN1194      BX61      1760      NO
BN1196      BX61      1740      YES
BN1198      BX61      980      NO


Do you want to see a separate list or restart the count to 3?

mlmcc
0
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

Author Comment

by:spudmcc
ID: 40589297
Either or will work for me.  Restarting the count would be most ideal as this would give me the maximum amount of results.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40589305
SO even though there is no correlation between the routes and truck id you want the 3 previous and subsequent records based on the order in the database?

Or are you grouping and sorting the data in the report?

mlmcc
0
 

Author Comment

by:spudmcc
ID: 40589313
Sorry, I misunderstood.  Yes there definitely a correlation between the two.   It MUST reset when it starts a new truck and doesn't include any records that aren't in that same truck.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40589316
So the data will be sorted by truck then by route then by drop?

mlmcc
0
 

Author Comment

by:spudmcc
ID: 40589323
That is true.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40611662
I am working on a possible solution.   I hope to have tomorrow.

mlmcc
0
 

Author Comment

by:spudmcc
ID: 40615143
Thank you so much for devoting so much time and knowledge to this question.  I am anxious to see what you come up with.

A
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40615295
I forgot about this last night.  I have a solution (I think) about half done.  Will try to work on it tonight.

mlmcc
0
 
LVL 101

Accepted Solution

by:
mlmcc earned 2000 total points
ID: 40615911
Here is a report that seems to do what you want.  I used the data you provided in a spreadsheet.

mlmcc
Truck-Routes.rpt
TruckRoutes.xls
0
 

Author Comment

by:spudmcc
ID: 40616410
This is fantastic!  I can't thank you enough.  Can you tell me the best way that I can print it out in the format that shows on the screen.  It seems to print your array and repeats the headers for every record.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40617014
Are you trying to print to a printer or are you exporting?

What version of Crystal?

Are you printing from the Crystal designer or an application/viewer?

mlmcc
0
 

Author Comment

by:spudmcc
ID: 40617059
Crystal Version 14.  I would like to export to Excel or comma delimited file.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 40617250
Export is nearly impossible to control especially if you only really want the data.  I'll see what I can do with that report.

mlmcc
0
 

Author Comment

by:spudmcc
ID: 40617602
Thank you again!
0
 

Author Closing Comment

by:spudmcc
ID: 40620879
Thank you so much for all of your help and time.   I value your patience and knowledge and thank you for all of your help.  I am closing this question and awarding the points at this point as I just can't ask you for any more attention to this issue.  Your solution provided me with what I needed.  By exporting as a PDF and bringing it into another tool I was able to get the format required.  Not a truly All-in-One solution but it did the trick.  Without your help none of it would have been possible.  This will save us tons of time and free up some all ready squeezed bandwidth.  

Andy
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question