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 a formula

Status
Not open for further replies.

ThaGooch

IS-IT--Management
Jun 10, 2003
9
US
I have created a variable out of my report I need to count. How do I count the number of times a formula is displayed. Example: If {@6000} then "Red". I want to count the number of times "Red" is displayed on my report in a summary total count. This count would show up in the footer of the group. I'm lost in space!
 
Create the following formula and place it in the same section as the formula that you want to count (Assuming that your exaple above is accurate):

iif({@6000},1,0)

You can now create a summary off this field for a grouping or your report footer.

~Brian
 
What about the instant of "Red" that is printed onto the report. That instance is what I need. I did this
iif({@6000},1,0) then "Red" ,and it will not except it. I may have explained myself wrong. I need to count the number of times "Red" is printed on the report. Then have the number of instances "number", in the group footer. It would be the total number of times it appears in a total count. I'm not sure if that sounds right.
 
You need two separate formulas. Your existing formula prints the word "RED", while the other is used for your total:

Use this formula:

If {@6000}
then 1
else 0

(this is essentially the same as BDReed's formula) and then do a grand total "SUM" of this formula. Don't add the word RED to it.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
Keep the formula I gave you seperate from whatever else you are doing. the iif statement just evalutes the condition that you used to set a font to RED.

~Brian
 
What if:

if {@6000} then "Red"

...is a formula called {@Formula}? Then what is really needed is:

iif({@Formula}="Red",1,0)

Then a summary could be inserted at the group level.

-LB
 
lbass:

If I do this to the formula I get "a Boolean is required here" , and highlights the "Red" in the statement.
 
Please show us the contents of the formula {@6000}. People are providing solutions based on guesses about what this is.

-LB
 
Sorry about that. The formula behind {@6000}
{@Productivity}<= 6000.00
 
Sorry, I think I have led you astray. Either of the earlier suggestions should work (without needing to include any reference to &quot;red&quot;:

if {@6000} then 1 else 0 //or use:

iif({@6000},1,0)

In either case, you would have to sum the formula, not count it, since 0 would also result in a count of 1.

-LB


 
I've done the same thing previously by using a running total. I set the field to evaluate as (using your verbage): @6000 and use 'count' as the summary type. For the evaluation, evaluate via formula such as: {@6000} = &quot;RED&quot; and then reset for each group.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top