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

manual running counts

Status
Not open for further replies.

mmwdmr

Technical User
Jan 10, 2002
119
0
0
US
Crystal 9
ODBC
My problem is twofold:

First, I am trying to count heads of household that are handicapped/disabled and heads of household that are not handicapped/disabled. "Y" represents handicapped/disabled and "H" represents head of household. My running counts evaluate the first statement but not the second. So, those heads of household that are not handicapped/disabled are not being counted. My evaluation formula is as follows:

WhilePrintingRecords;
NumberVar HDhead;
NumberVar HDother;

if (OnFirstRecord or {VW_DEMOGRAPHICS.TENANTID} <> Previous ({VW_DEMOGRAPHICS.TENANTID}) and
{VW_DEMOGRAPHICS.DISABLED} = "Y" and
{VW_DEMOGRAPHICS.RELATION} = "H") then
HDhead := HDhead + 1

else

if (OnFirstRecord or {VW_DEMOGRAPHICS.TENANTID} <> Previous ({VW_DEMOGRAPHICS.TENANTID}) and
{VW_DEMOGRAPHICS.DISABLED} = "Y" and
{VW_DEMOGRAPHICS.RELATION} <> "H") then
HDother := HDother + 1

Second, this formula counts the first record even if it doesn't fit the rest of the criteria in the formula. If I leave OnFirstRecord out, the first records running count field is blank. I am using the OnFirstRecord and table.field <> Previous table.field to avoid counting the same head of household twice (there are multiple records for the same head of household).

Any assistance is appreciated. Thanks!
 
Why not just use 2 Running Totals of distinctcount({VW_DEMOGRAPHICS.TENANTID}) and in the evaluate use a formula place:

Diabled RT:
{VW_DEMOGRAPHICS.DISABLED} = "Y" and
{VW_DEMOGRAPHICS.RELATION} = "H")

Not Disabled RT:
{VW_DEMOGRAPHICS.DISABLED} <> "Y" and
{VW_DEMOGRAPHICS.RELATION} = "H")

-k
 
Looks good. I'm at this client again next week and I'll give it a try. Thanks!
 
Oh, I am still curious about why my running total/count formula didn't work...
 
I think that you needed to change this:

{VW_DEMOGRAPHICS.DISABLED} = "Y" and

Not sure, but stick with the simpler means.

-k
 
I think the problem was the "or" statement was not set off with parens correctly. Try:

WhilePrintingRecords;
NumberVar HDhead;
NumberVar HDother;

if
(
(
OnFirstRecord or {VW_DEMOGRAPHICS.TENANTID} <>
Previous({VW_DEMOGRAPHICS.TENANTID})
) and
{VW_DEMOGRAPHICS.DISABLED} = "Y" and
{VW_DEMOGRAPHICS.RELATION} = "H"
) then
HDhead := HDhead + 1

else

if
(
(
OnFirstRecord or {VW_DEMOGRAPHICS.TENANTID} <>
Previous ({VW_DEMOGRAPHICS.TENANTID})
) and
{VW_DEMOGRAPHICS.DISABLED} = "Y" and
{VW_DEMOGRAPHICS.RELATION} <> "H"
) then
HDother := HDother + 1

-LB
 
That's what I was looking for - thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top