cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with counting first record

Former Member
0 Kudos

Post Author: John

CA Forum: Formula

Hey all. I thought I had my original problem fixed, but now, I have a new one.

The report is not counting the first record in the report. Here is the code....

WhilePrintingRecords;numbervar b;If {PRODUCT_INVENTORY.PRODUCT_ID} = "RBC" and {PRODUCT_INVENTORY.UNIT_NO} <> Previous ({PRODUCT_INVENTORY.UNIT_NO})Thenb := b + 1

Everything else is correct, it's just that the first instance (whatever product_id is equal too) is not counting.

Any suggestions?

Thanks

John

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Post Author: synapsevampire

CA Forum: Formula

Example data can be made up, and should be.

A set of example data and expected results will net great results, try it sometime.

-k

Former Member
0 Kudos

Post Author: John

CA Forum: Formula

synapsevampire:

Try supplying example data and the required output instead of descriptions.

We don't know why you are using "{PRODUCT_INVENTORY.UNIT_NO} <> Previous ({PRODUCT_INVENTORY.UNIT_NO})", right?

Nor how the report is grouped, where you are displaying the total, etc.

Now why would the counts vary based on what a fields value is? Weird logic...

You can always subtract 1 in that one instance, but I suspect that if you supplied example data and the expected output the logic would be very different.

-k

Hey, yeah, sorry the logic isn't as strong as you are probably used to. Newbie here just trying to weed through it.

Couple of answers for ya. Can't give exact example data as it is related to patient data. Sorry. The counts are based on the same field. That field can have 3 different values. Think of it this way. If the field was Blood Type and you wanted to count the # of O, A and B blood types. They would all be listed under the same heading in the report. As for why I was using Product <> Previous Product... well.. I had an earlier thread that dealt with this and this thread was "kinda" a continuation of that. No way you could have known that and I should have specified previously. Sorry for the confusion and thanks for the effort.

Have a good one!

John

Former Member
0 Kudos

Post Author: John

CA Forum: Formula

Jagan:

When you're on the first record what do you expect Previous() to do? Try adding OnFirstRecord, e.g.

WhilePrintingRecords;numbervar b;If {PRODUCT_INVENTORY.PRODUCT_ID} = "RBC" and (OnFirstRecord or {PRODUCT_INVENTORY.UNIT_NO} <> Previous ({PRODUCT_INVENTORY.UNIT_NO})) Thenb := b + 1

Thanks Jagan!

OnFirstRecord is what I was looking for. This fixed it right up.

Former Member
0 Kudos

Post Author: qcheng

CA Forum: Formula

Did you specify the initial value of b? It may work if create a new formula field called 'Initial' using the following code:

whileprintingrecords;

numbervar b:=0

and put the formula field 'Initial' in the section just before the first record and suppress it.

Former Member
0 Kudos

Post Author: Jagan

CA Forum: Formula

When you're on the first record what do you expect Previous() to do? Try adding OnFirstRecord, e.g. WhilePrintingRecords;numbervar b;If {PRODUCT_INVENTORY.PRODUCT_ID} = "RBC" and (OnFirstRecord or {PRODUCT_INVENTORY.UNIT_NO} <> Previous ({PRODUCT_INVENTORY.UNIT_NO})) Thenb := b + 1

Former Member
0 Kudos

Post Author: synapsevampire

CA Forum: Formula

Try supplying example data and the required output instead of descriptions.

We don't know why you are using "{PRODUCT_INVENTORY.UNIT_NO} <> Previous ({PRODUCT_INVENTORY.UNIT_NO})", right?

Nor how the report is grouped, where you are displaying the total, etc.

Now why would the counts vary based on what a fields value is? Weird logic...

You can always subtract 1 in that one instance, but I suspect that if you supplied example data and the expected output the logic would be very different.

-k

Former Member
0 Kudos

Post Author: John

CA Forum: Formula

I would, but, here's the problem.. The record set that I am counting can be 1 of 3 possibilities. So, it could be = to RBC, FFP, or PLT. If the first record is RBC, it would work, but, it could be FFP or PLT. So, if I start with b := 1, I have just as much chance of being +1 instead of even.

Thanks!

Former Member
0 Kudos

Post Author: yangster

CA Forum: Formula

are you always off by just 1?if so then just set b := 1 to start the count instead of b:= 0