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

Count Function 2

Status
Not open for further replies.

pig311

IS-IT--Management
May 3, 2002
4
I have a Formula that Checks a Date for aging. If the date falls within the parameter, then it prints the account balance. If it returns false, it will only let me enter a numeric value because the Acct Bal is numeric. Entering Zero for the value works for my totals, however it skews my count, because it counts all the zeros. Is there another way to return a null value if the select returns false, or maybe a way to have the count not count 0s?
 
Use a running total field to count the records, evaluate based on a formula, the formula would be {fieldname}<>0, reset = never or reset on change of group as the case may be.

Anotyher alternative is to use a record selection formula to totally exclude these records from the report, that way your counts will be accurate. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
or you could incorporate the counting into your formula

something like this

Set an initialize formula to set the total and count to zero in the group header

@Initialize

WhilePrintingRecords;
if not inrepeatedgroupheader then
(
Numbervar ReportTotal := 0;
NumberVar iCount := 0;
);


then in your formula that you are using do something like

WhilePrintingRecords;
Numbervar ReportTotal ;
NumberVar iCount ;
StringVar result := &quot;&quot;;

...(rest of your formula until here)....

If (Checks a Date for aging is true) then
(
ReportTotal := ReportTotal + {Table.AccountBalance};
Icount := Icount + 1;
result := totext({Table.AccountBalance},2);
);

result;

then later you will have display formulas to show the values for total and average...eg:

@display

WhilePrintingRecords;
Numbervar ReportTotal ;
NumberVar iCount ;

&quot;Total Account Balance: &quot; + totext(ReportTotal,2) +
chr(13)+ chr(10) + chr(13)+ chr(10) +
&quot;Average Balance : &quot; + Totext(reportTotal/icount,2) +
&quot; based on &quot; + totext(icount,0) + &quot;Non-zero accounts&quot;;


That should do it :)




JimBroadbent@Hotmail.com

Reward good advice with a star, it reinforces us and helps others find answers to their problems.
 
Thanks guys. I simply used the running total records with the logic to rule out 0s. I'm just begining and hopefully get to code like yours soon , Ngolem.

Thanks again, I'm sure I'll be back soon to tap your wisdom...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top