Normal Topic Report Totals (Read 1103 times)
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Report Totals
Sep 5th, 2009 at 4:25pm
Print Post Print Post  
I have 3 check-box fields and want a report to total the # of responses in each of the fields.

FirstName LastName Brunch Lunch Either
Joan Emelock               1  
Andrew Pacucci                      1  
Melvin Emelock                      1  
Spencer Wulwick                             1  
Renee Braun                1  
Marion Taub                 1  
Alan Taub                              1  
Maureen Pacucci                     1  
Francine Brandes                    1
Joel Brandes                           1
       
Total                            3         6        1


If I add a summary calculation of "count" I get "10" in each of the the 3 columns (the number of records retriefed)

If I add a summary calculation of "sum" nothing appears for the total of any of the 3 columns.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Report Totals
Reply #1 - Sep 5th, 2009 at 4:51pm
Print Post Print Post  
Typically, a check box is bound to a boolean field. Sum is not a valid operation on booleans. Booleans can only have a value of true (1) or false (0). The result of an sum operation is the same type as the field on which it is operating. So, a sum, resulting in a boolean doesn't make sense. Use a numeric field (that can count higher than 1), or use a count instead.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Report Totals
Reply #2 - Sep 5th, 2009 at 4:58pm
Print Post Print Post  
Mark -

I did try using a summary calculation of "count" (bound to the appropriate field); however, each count gives me a count of the total # of records rather than the number of records with a value of 1.
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Report Totals
Reply #3 - Sep 5th, 2009 at 5:14pm
Print Post Print Post  
Maybe I should rephrase: use a numeric field or count the values of "true" and set an unbound to the result in the footer.

Global Code:
Code
Select All
stat n as int

n = 0
 


Element to be Counted on Print (i.e.: "my_check_box")
Code
Select All
if(my_check_box = 1)
{
  n = n + 1
}
my_unbound_sum = n
 



As with any element type, a count gives you a count without regard to value.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Report Totals
Reply #4 - Sep 10th, 2009 at 2:47pm
Print Post Print Post  
Mark -

I tried working on this and could not get the results I wanted; I tried several variations (using the logic of what you were saying) got frustrated - let time pass so I could start fresh and just still don't get it.  

Here is my last effort

GLOBAL CODE

[code]
stat b as int
stat l as int
stat e as int
stat n as int

b = 0
l = 0
e = 0
n = 0
[/code]

I created 4 value boxes in the group footer and added the following code to each "matching" value box:

BRUNCHCALC

[code]
if(brunch = "1")
{
 b = b + 1
}
brunchcalc = b
[/code]

LUNCHCALC
[code]
if(lunch = "1")
{
 l = l + 1
}
lunchcalc = l
[/code]

EITHER CALC

[code]
if(either= "1")
{
 e = e + 1
}
eithercalc = e
[/code]

NOTATTENDING

[code]
if(NotAttending = "1")
{
 n = n + 1
}
NotAttendingCalc = n
[/code]


I get either a "0" or "1" in the first 3 value boxes (which is not a correct count) and only get the correct count in the "NotAttendingCalc" value box.


Do you think I'm not getting it because I had a "mental block" the first time I ever saw the report module ... or am I just getting "stupid" in my old age?  (lol)  Either way, I still need help to get this report right.   Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Report Totals
Reply #5 - Sep 10th, 2009 at 3:01pm
Print Post Print Post  
In your "if" statements you seem be checking a boolean value as though it were a string. You should probably not be using double quotes around the one in each of the cases your showed.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Report Totals
Reply #6 - Sep 10th, 2009 at 3:14pm
Print Post Print Post  
Mark -

I removed the quotes from all code and I still get the same results.  The only correct result (with or without the quotes) is for the NOTATTENDING value box. 

Any suggestions as to what else I might check for?

Thanks!
  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Report Totals
Reply #7 - Sep 10th, 2009 at 3:17pm
Print Post Print Post  
If you check the code I posted, you will see that the calculation has to be done in the On Print event of the element that is being counted, not in the group footer of that element. The On Print event runs for every row and therefore can count the rows with a particular value. The group footer only happens when the group breaks.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
SpencerWulwick
Senior Member
Members
*****
Offline



Posts: 677
Location: Wilton Manors, Florida
Joined: Jan 16th, 2005
Re: Report Totals
Reply #8 - Sep 10th, 2009 at 3:43pm
Print Post Print Post  
BRAVO!!!!

You figgered it out.  When I created the first field, I had just read your post and entered the code in the correct element.

After the "break" I took, I inadvertantly entered the code (for the 3 maining fields) in the wrong element.  Correcting my mistake did the trick.

Thanks very much for your patience and for helping me through it.  Hopefully, this will help me "get it right" (on my own) in the future.

By the way, I tried it both with and without the quotes around the 1(e.g. as in If brunch = "1") and it works just fine with or without the quotes.

Thanks again, Mark; I am delighted to have this out of the way and can now enjoy the intended value of the report.   Smiley

  

- Spencer

    ** Practice random kindness & senseless acts of beauty!
Back to top
IP Logged