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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional results does not concatenate correctly 1

Status
Not open for further replies.

lndoan

IS-IT--Management
Jun 30, 2005
28
US
I have a report that works fine displaying all the data that i need. The only problem is I have this formula which I think has a problem that I cannot figure out. The formula reads:

whileprintingrecords;
stringvar eqids;

If {TRIP_EQLINK_DTL.GROUP_ROW_ID} > 1 then
""
else
eqids := eqids & {RPT_TRIP_CONSISTS.Equipment ID} & ", "

The result prints 6 lines for every value and the value is duplicated twice for each equipment, for example:

SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624, where it should be only SCAX116, SCAX155, SCAX624. The first line in the details section shows 1 value = SCAX116, then every line will go SCAX116, SCAX116 then the next line is SCAX116, SCAX116, SCAX155 etc..

What am I doing wrong?? Any assistance is greatly appreciated.
 
I think you should check the value of {TRIP_EQLINK_DTL.GROUP_ROW_ID} by placing it in your detail section. If you are trying to accumulate figures based on the first value in the group field only, then you could instead change your formula to:

whileprintingrecords;
stringvar eqids;

If onfirstrecord or
{table.groupfield} <> previous({table.groupfield}) then
eqids := eqids & {RPT_TRIP_CONSISTS.Equipment ID} & ", ";

-LB
 
Thank you lbass,

The field {TRIP_EQLINK_DTL.GROUP_ROW_ID} stores train numbers and the value starts from row 0 to however many cars on a train running at that particular time. Row 0 is the locomotive which i do not want to include in the results, therefore, any data in row 1 on out is included which displays correctly. I tried your suggestion but it turned out almost similar to the result i currently have.

This formula:

whileprintingrecords;
stringvar eqids;

If {TRIP_EQLINK_DTL.GROUP_ROW_ID} > 1 then
eqids := eqids & {RPT_TRIP_CONSISTS.Equipment ID} & ", "
else
""
it now displays a little bit better... there are 3 rows return and and each row now contains 2 lines of data, but the last row contains all the data i want for example:

Results for this train now shows:

SCAX116
SCA116, SCAX116

SCAX116, SCAX116, SCAX155
SCAX116, SCAX116, SCAX155, SCAX155

SCAX116, SCAX116, SCAX155, SCAX155, SCAX624
SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624, <-- this is the row i want to show on a single line with all the other data that already displays. But it is DUPLICATING so i'm sure where i'm wrong.

Any help is greatly appreciated
 
And here I thought you ONLY wanted to show the first row. You need to create one more formula:

//{@display}:
whileprintingrecords;
stringvar eqids;

Remove the accumulation formula from the group footer and then add this formula instead. You can suppress the formula you have in the detail section so that it does not display.

-LB
 
Thank you again LB and we are steps closer to what I need. I forgot about the display formula. Now, all the data prints on one line but duplicating over and over again so train 100 has SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624 <-- still shows duplicated train#

train 101 has SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624, plus it adds on the same line and for every train, it adds an additional line so by the time you get to train 130, it has about 30 lines showing the same information when it should only show

SCAX116, SCAX155, SCAX620 for train 100 and if train 101 has 4 equipment, it should show SCAX116, SCAX155, SCAX620, SCAX626

You can tell that i'm not a programmer :) but I've been doing a good job developing over 50+ report except this one I think i came to a wall.... Thanks
 
Try changing your accumulation formula to:

whileprintingrecords;
stringvar eqids;

If {TRIP_EQLINK_DTL.GROUP_ROW_ID} > 1 and
instr(eqids,{RPT_TRIP_CONSISTS.Equipment ID}) = 0 then
eqids := eqids & {RPT_TRIP_CONSISTS.Equipment ID} & ", "
else
""

-LB
 
Thanks again but searching the string in eqids didn't really helped that much, the result is still duplicating for each train on each day specified:

Train 100 shows:
SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624,
Train 101 show:
SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624,SCAX116, SCAX116, SCAX155, SCAX155, SCAX624, SCAX624,
Train 102 shows: 1 more added to make it 3 duplicating lines..

Most of these 100 # trains only have 3 or 4 equipments so i'm just stuck now.

 
You ahve to reset it for each train with a formula like:

//{@reset}:
whileprintingrecords;
stringvar eqids := "";

This belongs in the train group header. If you had used the formula I gave you above, you would not see repeated values in the display, so please copy your formula into the thread.

What are your groups--only on train? And are you trying to show this for the train group?

-LB
 
Grouped First:
Train #
Trip Date
Details
Footer Train#
Footer Trip Date

In the details section, your formula suggestion of the following which I have already suppress the section.

whileprintingrecords;
stringvar eqids;

If {TRIP_EQLINK_DTL.GROUP_ROW_ID} > 1 then
""
else
eqids := eqids & {RPT_TRIP_CONSISTS.Equipment ID} & ", "

In the Group header for trip date i now have:

//{@reset}:
whileprintingrecords;
stringvar eqids := "";

In the Group footer for trip date i have:

//{@display}:
whileprintingrecords;
stringvar eqids;

The result is looking good since it now reset each trip to "" before printing the next one. But the result still shows duplicate value:

SCAX116, SCAX116, SCAX155, SCAX155, SCAX620, SCAX620 where it should be
SCAX116, SCAX155, SCAX620

I am selecting distinct records and suppressing duplicate entries. There is something in the code that i need to do for it not produce duplicate?


 
The formula in the detail section should be:

whileprintingrecords;
stringvar eqids;

If {TRIP_EQLINK_DTL.GROUP_ROW_ID} > 1 and
instr(eqids,{RPT_TRIP_CONSISTS.Equipment ID}) = 0 then
eqids := eqids & {RPT_TRIP_CONSISTS.Equipment ID} & ", "
else
""

-LB
 
THANK YOU LB, I REALLY APPRECIATE THIS, IT WORKS !! i'll do some customization to add stuff to the formulas and i think i understand the logic now.. thank you so much for your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top