Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Counting cells with SUMPRODUCT and conditionals...?

Hello, gurus –

I have a worksheet of resident data for an apartment building. The data is structured in such a way that each dweller has a record – which means that a family of four will show as 4 rows of data.

I want to simply find out how many adults and how many children are living in each apartment unit. I made three new columns on the attached spreadsheet (F, G, H) to populate the tally.

I found a nice SUMPRODUCT formula that counts the number of matching communityid, leaseid, and residenthouseholdid... This was a relatively simple way to identify multiple dwellers per unit. This is the formula in column F:

=SUMPRODUCT(--(A2&B2&C2=$A$2:$A$50767&$B$2:$B$50767&$C$2:$C$5076 7))

This gives me the total number of people in each apartment. But I need to divide it into adults and children. I've tried to play around with the formula, but I can't get it to work. Children are indicated in column E by both "Dependent" and "Minor Child" and I need to account for both in the formula. Here's what I had in column E, but it wasn't returning the correct value:

=SUMPRODUCT(--(L22="Dependent")*(A22&B22&C22=$A$2:$A$50767&$B$2: $B$50767&$C$2:$C$50767)

The section of the worksheet in red easily highlights my goal. What I'm looking for are "4"s in all 4 family records for this apartment (which is already fine) AND all "2"s in all 4 records as well.

I can then perform a simple difference between columns F and H to fill in the number of adults in each apartment.

Can anyone help me?
Attached Files
File Type: zip sandbox.zip (37.0 KB, 53 views)
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 829
Default Counting cells with SUMPRODUCT and conditionals...?

"numerologist" wrote:
I found a nice SUMPRODUCT formula that counts the number
of matching communityid, leaseid, and residenthouseholdid
[....] This is the formula in column F:
=SUMPRODUCT(--(A2&B2&C2=$A$2:$A$50767&$B$2:$B$50767&$C$2:$C$5076 7))


Although that might work, I think the following is a more intuitive and more
typical way to write that logic:

=SUMPRODUCT(--(A2=$A$2:$A$50767),--(B2=$B$2:$B$50767),--(C2=$C$2:$C$50767))

or equivalently:

=SUMPRODUCT((A2=$A$2:$A$50767)*(B2=$B$2:$B$50767)* (C2=$C$2:$C$50767))

We debate ad nauseum about which might be more efficient. Recent careful
measurements suggest that there is no statistical different. So it just a
matter of personal preference.


"numerologist" wrote:
This gives me the total number of people in each apartment.
But I need to divide it into adults and children.
[....] Children are indicated in column E by both "Dependent"
and "Minor Child" and I need to account for both in the formula.

[....]
I can then perform a simple difference between columns F and H
to fill in the number of adults in each apartment.


In H2:

=SUMPRODUCT((A2=$A$2:$A$50767)*(B2=$B$2:$B$50767)* (C2=$C$2:$C$50767)
*({"Dependent","Minor Child"}=$E$2:$E$50767))

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Counting Blank cells using evaluate(=sumproduct) Gwen Excel Programming 3 November 29th 06 12:08 AM
=SUMPRODUCT formula is counting the blank cells as well as zero's JR Excel Worksheet Functions 2 March 16th 06 03:39 PM
=SUMPRODUCT formula is counting the blank cells as well as zero's JR Excel Worksheet Functions 1 March 16th 06 02:46 PM
sumproduct--counting--zero--blank cells jeremy via OfficeKB.com Excel Discussion (Misc queries) 4 August 16th 05 03:22 PM
sumproduct and conditionals Gixxer_J_97[_2_] Excel Programming 8 June 2nd 05 06:50 PM


All times are GMT +1. The time now is 06:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"