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

Counting from another formula 2

Status
Not open for further replies.

madvalpreston

Technical User
Apr 7, 2011
142
GB
HI

We have a complex formula with which I want to sea count on where the result is OTIF. I cannot get it to count no matter what syntax i try in my formula. Please see below tjhe two formulas, the complex and then mine trying to count

shared numbervar counter;
shared numbervar OversCounter;
shared numbervar LateCounter;
shared numbervar NotShippedCounter;

// Is Actual shipped by date earlier than actual shipped dated?
//If {BAQReportResult.ShipHead.ShipDate} <= {BAQReportResult.OrderRel.ReqDate} AND {#Total_Qty_Shipped} >= 0.9 * {BAQReportResult.OrderRel.SellingReqQty} AND {#Total_Qty_Shipped} <= {BAQReportResult.OrderRel.SellingReqQty}

If {BAQReportResult.OrderRel.OpenRelease} = True Then
(if {BAQReportResult.OrderRel.ReqDate} <= CDate({BAQReportParameter.Option02}) Then
NotShippedCounter := NotShippedCounter +1; "NOT SHIPPED"
)

Else
( //Start of closed releases

If {BAQReportResult.ShipHead.ReadyToInvoice} = True

THEN
If {BAQReportResult.ShipHead.ShipDate} <= {BAQReportResult.OrderRel.ReqDate} AND {#Total_Qty_Shipped} >= 0.9 * {BAQReportResult.OrderRel.SellingReqQty} AND {#Total_Qty_Shipped} <= {BAQReportResult.OrderRel.SellingReqQty}

THEN ( counter := counter + 1; "OTIF";)

//ELSE "LATE/NOT_ENOUGH"

Else If {BAQReportResult.ShipHead.ShipDate} <= {BAQReportResult.OrderRel.ReqDate} AND {#Total_Qty_Shipped} > {BAQReportResult.OrderRel.SellingReqQty}

THEN (OversCounter := OversCounter +1; "OVER";)

ELSE (LateCounter := LateCounter +1; "LATE")

ELSE IF isnull({BAQReportResult.ShipHead.ReadyToInvoice}) OR {BAQReportResult.ShipHead.ReadyToInvoice} = False
THEN (NotShippedCounter := NotShippedCounter +1; "NOT SHIPPED")
)//End of closed releases


THEN MINE

whileprintingrecords;
Shared numbervar totalcount;

If {@LATENESS_SHIPQTY_CHECKER}= "OTIF"

THEN totalcount := totalcount + 1



I need it to add one every time it shows OTIF.

Any ideas please

Thanks
 
You need to create another formula, call it RESET, with the following expression:

whileprintingrecords;
shared numbervar totalcount = 0

(actually you don't need the shared since you are not using sub-reports)

Put RESET in the Report header band

Put your formula in the record band

Create one more formula, call it SHOW

whileprintingrecords;
shared numbervar totalcount;
totalcount

Pleace this where you want the total to be displayed.

Note to LBASS: I know that the code could be tighter.



Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Hi Howard

Thanks for the reply, I dont quite understand.

1. I create the RESET and out in report header

2. Create Show and out it in the report footer

What i dont understand is where you say put your formula in the record bamd????? Which formula.

Thanks
 
I am mixing up my report writers. Put YOUR formula in the detail section. You can't reference a variable without declaring it first.

Put RESET in the report header section. You can format it with the color White so it does not show.

Put the following in the detail section:

whileprintingrecords;
Shared numbervar totalcount;
If {@LATENESS_SHIPQTY_CHECKER}= "OTIF" THEN totalcount := totalcount + 1 else totalcount

Put SHOW in the report footer.

Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
FREE independent Crystal newsletter
howard@hammerman.com
800-783-2269
 
Are you resetting these shared variables at some group level? Or are you ONLY looking for a grand total summary? If so, then you should be able to just use a formula like this in the report footer:

whileprintingrecords;
shared numbervar counter;

If this variable IS being reset at some group header level, then in the group footer section where the result is displayed, add a formula like this:

whileprintingrecords;
shared numbervar counter;
shared numbervar totalcount := totalcount + counter;

Then display the result in the report footer:

whileprintingrecords;
shared numbervar totalcount;

-LB
 
Hi All

It was a full report total. I have followed Howards example and it works now. I have count of OTIF

I may want it in the groups we have on the report instead, but will face that one if the users request it.

Many thanks for the replies.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top