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

Incorrect Formula results

Status
Not open for further replies.

awise

IS-IT--Management
Dec 11, 2001
85
I have the following formula:
Code:
NumberVar LoopCounter := 1;
NumberVar CompCounter := 0;

For LoopCounter := 1 to Count({exmaster.Col008}) Step 1 Do
(
    if {exmaster.Col008} = "/reports/crystal/jbiocca/SalesbyTerrCustProduct.rpt" then CompCounter := CompCounter + 1
    else CompCounter := CompCounter;

    LoopCounter := LoopCounter + 1;
);

CompCounter := CompCounter/3

This should return a value of 2 total. The dbase has 6 entries, but every three entries denotes one access to the log file it pertains to. So, the result should be 2 total, without the division by 3, a total of 6. However, it is giving me a total of 3 with the division, and 9 without the division. Am I doing something incorrect within the loop?

Thanks in advance,

David
 
I don't think that you want a loop here, use 3 formulas:

//Reset the counter (Report Header???)
whileprintingrecords;
Global numbervar MyCounter:= 0;

//Detail section
whileprintingrecords;
Global numbervar MyCounter;
If {exmaster.Col008} = "/reports/crystal/jbiocca/SalesbyTerrCustProduct.rpt" then

//Display section
//Reset the counter (Report Header???)
whileprintingrecords;
Global numbervar MyCounter;
MyCounter

-k
kai@informeddatadecisions.com
 
Synapse,

Thanks for your suggestion, I believe I took part of your suggestion and part of my own little concoction to solve the problem!! Looks to be working perfectly now!!

Dave
 
For LoopCounter := 1 to Count({exmaster.Col008}) Step 1 Do (
your loop
LoopCounter := LoopCounter + 1 )

The line in red is probably causing your problem. It's not needed. Your LooopCouunter, if your could display it's value would be 1, 3, 5, etc. Mike
If you're not part of the solution, you're part of the precipitate.
 
Ooops, sorry, i didn't paste the details section correctly:

//Detail section
whileprintingrecords;
Global numbervar MyCounter;
If {exmaster.Col008} = "/reports/crystal/jbiocca/SalesbyTerrCustProduct.rpt" then
MyCounter := MyCounter+1 kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top