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

Formulas & Variables

Status
Not open for further replies.

iamtrying

Technical User
Sep 28, 2004
128
US
Hello all,
I have created five separate reports, but I am trying to enhance my reporting skills by moving from selection experts to formula variables. With variables, I can show all of the data in one report.

I have a table with the following fields complaint, compliment, operator, date_recd and code. These fields are strings with the exception of the date_recd field which I converted to a date field. I would like to count all of the “Complaints” the field is populated with an “X”
I have declared and placed this in the Group Header

//Reset
WhilePrintingRecords;
Global Numbervar CompCount:= 0;
Global Numbervar CompCount:= CompCount + 1;

Placed this in the Group Footer
WhilePrintingRecords;
Global Numbervar CompTotal;
Global Numbervar CompTotalGT;
If {BCT_CUST.COMPLAINT}= "X" Then
(CompTotal:= CompTotalGT + 1);

I know I need to convert the string to a number for counting purposes, but I need help.
Thanks
 
Almost had it right. I use shared variables instead of global as personal preference.

In report header
//@InitCompGT
shared ComTotalGT := 0;

In Group Header
//@ResetCompCount
WhilePrintingRecords;
shared numbervar CompCount:= 0;

In the detail section

//@CountComp
WhilePrintingRecords;
shared numbervar CompCount;
If {BCT_CUST.COMPLAINT}= "X" Then
CompCount:= Compcount + 1;

In the group footer

//@CompCountGT
WhilePrintingRecords;
shared Numbervar CompCount;
shared Numbervar CompTotalGT;
If {BCT_CUST.COMPLAINT}= "X" Then
CompTotalGT := CompTotalGT + CompCount;


In group Footer b

//@ShowCompCount
shared numbervar compcount;
compcount

In report footer

//@ShowGrandTotal
Shared numbervar CompTotalGT;
CompTotalGT

-lw


 
If the complaints field is either null or equal to "X", all you need to do is right click on the field in the detail section->insert summary->count. You can insert the summary at the group and/or grand total level.

-LB
 
Thanks guys,

lbass you are correct. However, I am trying to incorporate data for five different reports into one.
 
One sheet of paper instead of five sheets.
 
I don't understand your response. The simplest way to do a count is just to insert a summary. I am asking you why you think it won't work in this case. There is nothing in your variable formula that suggests it couldn't be replaced by a simple inserted summary. The fact that you are trying to integrate five reports into one does not explain this. Using variables should be a last resort in most cases.

Maybe you should provide a sample of your data, and then a sample of the results you are trying to achieve.

-LB
 
You are correct, but I just can't get all of the information on one sheet of paper with running totals and the selection experts. I can easily accomplish the task with variables. All is well, and again thanks.
 
Using variables or inserted summaries does not affect the amount of space used in a report, so I am confused, but if you are all set, then I won't belabor this point.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top