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

Need calculate each detail

Status
Not open for further replies.

tjones3d

Programmer
Sep 2, 2009
8
US
I have 1st column {OPERATION.SEQ_NO} AND 2nd column{OPERATION.COMPLETED_QTY} on detail section. The data shows:

1st: 2nd:
10 340
20 293
30 260
40 264

If the 2nd column number is lower than the row above, I need the difference on the lower row as 3rd column. See sample that I need on report below:

1st: 2nd: 3rd:
10 340
20 293 11
30 260 43
40 264

If the number is higher than the number above, the 3rd column is blank.

How do I do this?
I am using CR XI
TIA
 
create a formula

if previous({2nd}) > {2nd} then
previous({2nd}) - {2nd}
else 0


place that where you want it in the details
If you want to suppress the 0 then right click your formula field - select format field - select the common tab then select the suppress option - click the formula icon and enter
{@yourformula} = 0


_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
whups

if previous({2nd}) > {1st} then
previous({2nd}) - {1st}
else 0



_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
scratch that second post.. I had it right the first time


_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
I had to change this around because of adding tables created duplication. Now I put this in GF of 1st column. How do I make it read from GF instead of detail?

I put the formula in GF and it gave me 0.

Can this be done to fix it?

TIA
 
Can we assume you grouped on {table.1st} and that {table.2nd} has the same value for each record within the group? If so, create a formula like the following and place it in the group header:

whileprintingrecords;
numbervar curr;
numbervar prev := curr;
curr := {table.2nd};
numbervar diff;
if curr < prev then
diff := prev-curr else
diff := 0;

Right click on the formula->format field->number->customize->suppress if 0.

-LB
 
Whew, this works in the GH. Too bad it doesn't work on the GF, but I can try to make it look nicer. Thanks so much.:-D
 
Try this in the group footer.

whileprintingrecords;
numbervar curr;
numbervar prev := curr;
curr := maximum({table.2nd},{table.1st});
numbervar diff;
if curr < prev then
diff := prev-curr else
diff := 0;

-LB
 
I've already gone further in CR so I will not change it at this time, but this will be handy down the road. Thanks so much. Now, I have come to a wall here.

In GH

1st: 2nd: 3rd: 4th: 5th:
10 340 0 $10.85 $0
20 329 11 $16.73 $184.03
30 296 33 $18.31 $604.23
40 297 0 $18.88 $0
50 295 1 $21.01 $21.01

(The 4th is a RunningTotal formula for the cost cummulated for each line.) 5th is the total = 3rd X 4th. I need to sum the 5th column. Is there a way to do this? TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top