View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.newusers
Max
 
Posts: n/a
Default Compare columns and get a percentage

See new sheet: Summary (2),

Revised sample file available at:
http://cjoint.com/?docV3pyW4H
CalcPercent_n_ExtractLists_Matched_n_UnMatched_V2. xls

In C2:
=SUMPRODUCT((X!E2:E10=A2)*(X!F2:F10=B2))/COUNT(X!E:E)

In D2:
=SUMPRODUCT(((X!E2:E10=A2)*(X!F2:F10<B2))+((X!E2: E10<A2)*(X!F2:F10=B2)))/C
OUNT(X!E:E)

In E2: =100%-SUM(C2:D2)

C2 gives the Matched% (Census & Blk)
D2 returns the Matched% (Census OR Blk)
E2 yields the Unmatched%

(Adapt the ranges X!E2:E10, X!F2:F10 to suit,
but note that we can't use entire col refs)

Criteria cols F to H
(for extract of names for each of the 3 categories)
-------------------------------
In F2:
=IF(OR($A$2="",$B$2=""),"",IF(AND(X!E2=$A$2,X!F2=$ B$2),ROW(),""))

In G2:
=IF(OR($A$2="",$B$2="",X!E2="",X!F2=""),"",IF(AND( ISNUMBER(X!E2),ISNUMBER(X!
F2)),IF(OR(AND(X!E2=$A$2,X!F2<$B$2),AND(X!E2<$A$ 2,X!F2=$B$2)),ROW(),"")))

In H2:
=IF(OR($A$2="",$B$2="",X!E2="",X!F2=""),"",IF(AND( F2="",G2=""),ROW(),""))

Select F2:H2, copy down as far as required
to cover the max expected extent of data in X

Then placed in C4 (as before, no change):

=IF(ISERROR(SMALL(E:E,ROW(A1))),"",
INDEX(X!$G:$G,MATCH(SMALL(E:E,ROW(A1)),E:E,0)))

Copy C4 to E4, fill down to the extent done
for the criteria cols F to H

C4 down returns the Matched Names (Census & Blk)
D4 down returns the Matched Names (Census OR Blk)
E4 down returns the Unmatched Names
(All names will be neatly bunched at the top)

Lightly tested here, the above seems to return correctly the required
results. Try it out on your actual data ..
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"Kirk Pepper" wrote in message
...
Ok after further review - the result was not as expected. The numbers in

the
group's columns represent text only.
I get a mixed result when I did a visual comparison.

Therefore, to clarify,

If there is a 2 in the census group and a 2 in the Block Group then that
meets the criteria for the name to be listed.

Next if there is a 2 in either the census group or Block Group with some
other number, that meets the criteria for the name to be listed.

Then any one without a 2 in either census group or Block Group would be
listed.

And a percentage given to each of these i.e.: 25% are 2-2, 25% are 2-1,

50%
are other.

I am sorry if I didn't explain myself well enough the first time, and I am
sorry I can't post the whole sheet - I got my but chewed for what little I
did put up. I like what you did it just didn't quite give me what I need.