Showing posts with label counts. Show all posts
Showing posts with label counts. Show all posts

Friday, March 9, 2012

Question about counting records based on conditions

Hi all,
I'm doing some reports where counting records is extensively used; some of these counts have to be done based on some data in the returning records; for example, I've got the following data set:

Name Sex IsMember
-- -- ----
... M Y
... F N
... M N

and so on...

If I group my report based on 'Sex' field, for example, I would like my report to show group name (M or F), number of members in this group (1 male member) and number of non-members in this group (1 non-member male), so the report should be something like:

Male - 1 member and 1 non-member
... *records where Sex = M will go here* ...

Female - 0 member and 1 non member
... *records where sex = F will go here* ...

So, how can I do counting based on some conditions in the retured data within a group?

Any hint will be very much appreciated,

Thanks in advance,

Essamyou can create a formula field that calulates where the person is male or female and member or non-member

if sex = "M" and Member = "Y" then
"Male Member"
else sex = "M" and Member = "N" then
"Male Non-Member"

etc.

You can then create formulas to count the number of each value or you can create a cross tab report that will group them for you.|||Thanks abyerly for your reply, and sorry I saw your post just today!

Well, my problem was solved by this reply I got from someone called MrBill somewhere in the web :) and yes it is what I was looking for, and as I was doing it in groups, it was better to do it this way:

You would group on sex and create two formulas:
// formual @.MemberCount
If {table.IsMember} = "y" then 1 else 0

// formula @.NonMemberCount
If {table.IsMember} = "n" then 1 else 0

Place the formulas in the detail section. You can suppress them if you want. For each formula do the following:
Right click > Insert > Summary. In the "calculate this summary" box select 'sum'. In the summary location box select group 1 (sex). Click ok. This will place a sum of your formula fields in the group 1 footer. Drag the 'sum' fields to the group header if you want or leave in the footer.