count or percentage of fields with value... in a colomb.
I am searching for a formula (in crystal reports 8.5)
- to count the fields in a colomb {JobRecStatus} which value is equal to 4.
- to calculated the percentage fields in a colomb {JobRecStatus} which value is equal to 4.
(all the fields in this colomb are 100%) how many fields are "4".
Re: count or percentage of fields with value... in a colomb.
Three Formulas
1. In Report Footer section, to count all the rows
2. In Detail section to count only the rows in wich the field is = to 4
3. In Report footer section to calculate the percentage of rows in wich the field value is = 4
It's good time to learn
Re: count or percentage of fields with value... in a colomb.
How do these formulas (2 and 3) look like?
Re: count or percentage of fields with value... in a colomb.
1. Insert a Summary field Counting the field {TableName.JobRecStatus}
Place it in Report Footer (well it place by itself)
Format Field / Suppress
2. Insert a new Formula field
Let's call it MyCounter
Place it in Detail Section
Format Field / Suppress
I'm assuming that JobRecStatus is a string type field
If it's numeric then remove Trim() function and change to 4 instead of "4"
Code:
WhilePrintingRecords;
numberVar Counter ;
If Trim({TableName.JobRecStatus})= "4" Then Counter := Counter +1;
Counter;
3. Insert a new Formula field
Let's call it MyPercent
Place it in Report Footer Section
Code:
WhilePrintingRecords;
numberVar PerCent;
Percent := {@MyCounter} * 100 / Count ({TableName.JobRecStatus});
PerCent;
Just change TableName by your table's name
JG