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

how to do a count by using two conditions 2

Status
Not open for further replies.

cnu29

Programmer
Jul 2, 2010
1
US
Hi I am new to crystal reports, I facing problem to generate a report can any one help, my sample table is below,

name district typeofChange
xxx DC hh
xyz NC hh
xzx DC shelter
qwe NC earning
wqew NC shelter
ret DC earning
TERE DC hh

Now i want ot create a report that will look like this

DISTRICT TOTALCHANGE HH Shelter earning
DC 4 2 1 1
NC 3 1 1 1


now how can i achive thi, I tried using the running total but I coudnt get the exac result, can any one help me, i want to do a groupby district and count records for each type of change.

Thanhks in advance

 
The easiest way is to insert a crosstab in the report footer
using

district as rows
tupe of change as columns
count of name as summary

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
If you do not want/can't use a crosstab, which does seem the easiest to implement, then I think you should be able to do this using Running Totals.
Field to Summarize would be your unique identifier (name?) and the type would be distinct count, in the Evaluate area, 'Use a Formula' x+2 box and enter the criteria, and Reset = Never.


Or, perhaps, if running totals are uncooperative....create accumulation formulas to put in the details to count up the records and then place display formulas in the footer to show the totals.

{@DCHH_accum} //For details
whileprintingrecords;
numbervar dchh;
IF {table.district} = "DC" and {table.typeofchange}="hh"
then dchh := dchh+1
else dchh := dchh;

{@DCHH_disp} //for footer
whileprintingrecords;
numbervar dchh;
dchh



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top