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!

Calculation for percent 2

Status
Not open for further replies.

lismiss

Technical User
Mar 23, 2002
5
US
Crystal reports version 8.
This is probably really easy to do but I'm not good with formulas:
I have 2 fields {testcode} and {Flags}.
example of table:

Testcode Flags
KP *
KP *&^
KP
KP
KP *&@

I want to count the number of listings under flags that contain the symbol * and divide it by the total number of listings for testcode (KP) and then multiply the result by 100. How do I write a formula that does this and returns me the answer?
thanks much.
 
No problem:

1) create a running total (Total0) that counts the field testcode. In the evaluation section click on "use a formula" and click on the icon. In the expression enter the fillowing:

{table.testcode}="KP"

Reset at a group or the grand total as needed.

2) Create a running total (Total1)that counts the field flags. In the evaluation section click on "use a formula" and click on the icon. In the expression enter the fillowing:

{table.flags}="*"

Reset at a group or the grand total as needed.

3) Create a formula field as follows:

(Total1*100)/Total0

that is it!
Howard Hammerman,

Crystal Reports training, consulting, books, training material, software, and support. Scheduled training in 8 cities.
howard@hammerman.com
800-783-2269
 
Those formulae from Howard should do the trick for you, if you only want to total those flags that equal *, and not those that have other characters in the string.

In your original request I kinda got the impression that you wanted to include flags that included asterisks, as well as those that equalled asterisks.

If so, then rather than total {table.flags} that = '*' you really want to use the 'like' component. Unfortunately, you're trying to count the same symbol which is the wildcard character in the 'like' function!

So, if you want to include flags like '*&^' as well as '*' in your percentage calculation, use Howard's solution. But before step (2), create a formula like:

if '*' in {table.flags} then true else false

Then simply make the running total in Howard's step 2 total the occurences of 'True's, and base your percentage forumla on that.

Hope this helps, but if this solution raises any queries, gimme a shout.

Naith
 
thanks so much, that worked fine-I had to use the "like" component.
Now, maybe you can help me with one more thing. There is an additional column( field name="result) that has numbers for each row. 4.5, 6.7, 2.3 etc. I want to calculate what the mean and 2 standard dev's would be for that entire column.
 
Do you want to apply the same condition as in your first problem? If so, use the same logic in separate running totals for the mean and the standard deviation. You have to create two running totals, Crystal can't do it in one shot.
Instead of a 'count' or 'distinct count' pick the field and pick standard deviation or mean.

If you don't need to apply the same condition, then just create two 'normal' totals (right click on the field, pick insert, pick summary, pick mean or s.d.) Howard Hammerman,

Crystal Reports training, consulting, books, training material, software, and support. Scheduled training in 8 cities.
howard@hammerman.com
800-783-2269
 
thanks so much. Your help was excellent!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top