I have an Excel worksheet with data in multiple columns. In column P, data has one of four values (1, 2, 3, or 4). Column Q has one of two values (L or S); Finally, column W has one of two values (y or n) (for yes or no). I want to Count the # of times there was a “y” in Col W when there was,say, 2 in column P and “L” in column Q. While its easy to use the following fml — IF(AND(P7=2,Q7=”L”,W7=”y”),1,””) — as an example, this only processes data in one row and cannot be used for counting, whereas I want to COUNT across multiple rows in the worksheet where the specified conditions (2 in column P, “L” in col Q, “y” in col W) were true in any given row. Once I figure that out, I wil modify it to Count other combinations also (e.g. 1/L/y, 1/S/y, 4/S/n, etc.)
Please help. I am completely stumped!
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Referencing 3 columns for a result (2002 SP-2)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Referencing 3 columns for a result (2002 SP-2)
- This topic has 21 replies, 5 voices, and was last updated 20 years, 2 months ago.
AuthorTopicWSStumped
AskWoody LoungerJanuary 29, 2005 at 10:37 pm #415230Viewing 0 reply threadsAuthorReplies-
H. Legare Coleman
AskWoody PlusJanuary 29, 2005 at 11:28 pm #925438The following array formula should work for up to 100 rows of data. If you have more than 100 rows, then change the three occurances of 100 to whatever is appropriate. Again, this is an array formula, so hold down Ctrl and Shift when you press Enter to confirm the formula.
=SUM((W1:W100="y")*(P1:P100=2)*(Q1:Q100="L"))
-
WSStumped
AskWoody LoungerJanuary 30, 2005 at 3:06 pm #925506Thanks for the quick reply! I have never worked with an array fml before so the tip to use Ctrl-Shift-Enter was extremely useful. Out of curiosity, I have a few more Qs:
– if I later insert a new row and insert new data, will the array fml automatically extend its range to include this new row or will I be required to manually update the fml itself?
– the asterisk sign (*) in the fml – is it just a separator or does it imply multiplication as in a standard formula?
– the current array fml uses 3 conditions; what is the maximum # of conditions one can use in an array fml and are they all required to be enclosed in parentheses? -
WSAladin Akyurek
AskWoody LoungerJanuary 30, 2005 at 7:46 pm #925528Q1. Answer: No. However, the following setup would take care of that.
Assuming that P is numeric and the data starts at row 7…
A1:
=MATCH(9.99999999999999E+307,P7:P65536)
The formula would become, using Sumproduct instead of Sum:
=SUMPRODUCT(–($W$7:INDEX($W$7:$W$65536,$A$1)=A2),–($P$7:INDEX($P$7:$P$65536,$A$1)=B2),–($Q$7:INDEX($Q$7:$Q$65536,$A$1)=C2))
where A2 houses a value like “y” (without double quotes, B2 2, and C2 “L”.
This formula needs just enter instead of control+shift+enter.
Q2. The Sum formula operates on arrays as the SumProduct formula. The star [ i.e., * ] might be thought of as a multple-value AND. It effects vector (matrix) multiplication. The evaluation of a conditional yield a truth-valued vector, that is, something like {TRUE,FALSE,FALSE,TRUE,…}. This set is first coerced into a numerical vector, that is, something like {1,0,0,1,…}. In Excel, 1 and 0 are numerical equivalents of TRUE and FALSE, respectively. After coercion, vectors are multilied and summed. The same thing happens when we use SumProduct. Double negation takes care of coercion. The comma in SumProduct stands for multiplication.
Q3. Answer: 30. The conditionals indeed must be put between parens.
-
WSStumped
AskWoody Lounger
-
-
H. Legare Coleman
AskWoody PlusJanuary 30, 2005 at 9:22 pm #9255491- No, the formula will not automatically adjust for added rows. However, because of the way this particular formula works, you can specify a row that is greater than the maximum you will ever have (i.e. you could specify row 1000 even though you only have 100 rows in the current sheet). That would not work in all formulas like this, but it will in this case.
2- Yes, the * in the formula indicates multiplication. When you use Excel boolean expressions, they return a 1 for true and a 0 for false. Therefore, if you multiply three comparison expressions together, you will get 1 if all are true and 0 if any are false. If you add those up, you get a count of the number of times all three expressions were true.
3- The maximum number of conditions is restricted by the maximum size of any formula.
-
WSStumped
AskWoody LoungerJanuary 30, 2005 at 10:18 pm #925556A new wrinkle has appeared. I decided to drop col Q from consideration and instead added col Y which has percentage (%) values. Now I want the formula to add the % values in column Y when the conditions in columns P and W are met. Put another way, if W7=”y” and P7=2, then add % value in Y7, and then repeat this for the entire data set up to row 123 (my data currently extends from row 7 to row 123). Thus, I wrote:
{=SUM(($W7:$W123=”y”)*($P7:$P123=2)*($Y7:$Y123>0))}
but this gives the same value as {=SUM(($W7:$W123=”y”)*($P7:$P123=2)}. Then I tried various other methods – such as replacing SUM by SUMIF or putting in an IF condition, like
=IF(($W7:$W123=”y”)*($P7:$P123=2),SUM($Y7:$Y123))
etc. – but I either got an error message from Excel saying the fml was incorrect or I got #VALUE in the cell or I got a value of 0 or I got the same result as {=SUM(($W7:$W123=”y”)*($P7:$P123=2)}. Bottom line: inspite of various permutations, I can’t get Excel to add the % values in column Y when the 2 specified conditions in columns W and P are met. Please help as this really has me stumped! -
H. Legare Coleman
AskWoody Plus -
WSStumped
AskWoody Lounger -
H. Legare Coleman
AskWoody PlusJanuary 31, 2005 at 2:24 pm #925655$y7:$y123 was not in parenthesis because there was no comparison there to cause possible operation precidence problems. The parenthesis around the others are to insure that the comparison is done before the multily.
The error you are getting indicates that one or more of the values in $y7:$y123 is not a numeric value. Is one or more of your percents entered as text rather than a numeric value?
-
WSStumped
AskWoody Lounger -
H. Legare Coleman
AskWoody Plus -
WSStumped
AskWoody LoungerJanuary 31, 2005 at 6:02 pm #925705Legare, while I was preparing a copy for upload and clearing out some rows, I noticed that once I cleared the lowest rows (117 to 123) that do not have any data (but do have certain formulas in individual cells), your condition returned a value, as if like magic! In other words, if your condition references cells that have certain formulas but no value as yet (which will come at a future date), it returns a #VALUE error, but if I limit the reference just to the cells with (formula-calculated) values, it does work.
I guess to make your condition work, I must limit the reference to cells with values but then it would become tedious to manually alter the condition each week (data is added each week to the spreadsheet; each row refers to 1 week of data) to refer to new cells with data. Is there a workaround? I tried as follows:
{=IF(ISERROR(your formula),””,your formula)}
but this just returned a blank (“”). Any other workaround? What about Aladdin’s solution using SUMPRODUCT – it went right over my head but maybe you can explain it in simple English and maybe it will work? Or any other trick that you know of. -
H. Legare Coleman
AskWoody PlusJanuary 31, 2005 at 6:23 pm #925706Again, could you upload a workbook that shows the problem (without cleaning up rows 117 to 123). It is most likely that those formulas can be changed to allow my formula to work properly, but I can’t tell without seeing what they are doing. Aladdin’s formula would probably give the same result as mine since his formula is just a different way of doing the same thing.
-
H. Legare Coleman
AskWoody PlusJanuary 31, 2005 at 6:42 pm #925708 -
WSStumped
AskWoody LoungerJanuary 31, 2005 at 9:03 pm #925738 -
WSAladin Akyurek
AskWoody Lounger -
H. Legare Coleman
AskWoody PlusJanuary 31, 2005 at 10:48 pm #925765The order of precedence is important in all statements with more than one operator. In this case, the order of the multiplications does not make any difference. 1*1*0 will get the same result as 1*0*1 or 0*1*1. I put them in that order because that is the order you specified them in in your post, and since the order was not important, I just did them in the order you typed them.
-
WSStumped
AskWoody Lounger -
WSAntediluvian
AskWoody LoungerFebruary 26, 2005 at 6:57 am #931303Hoping I’m not too late here, but I have a similar problem (wanting to count and sum rows in a table that match criteria based on the contents of a number of columns). I know I’m a bit slow on array formulae, so I looked for an alternative. I found DCOUNT. This function references a table (for the counting), and also a Criteria Table. This Criteria Table can check on multiple criteria (I think it’s the same as the Criteria Tables in Advanced FILTER (Data / Filter / Advanced Filter )). So, for example, using Conditional Criteria I could check on the number of characters in cells in a column, whether a column cell contained a certain character, etc, etc. Moreover I can do OR’s and ANDs. Thus I can select the rows to count. Using DSUM I can total a column in a similar way. I’m hoping these techniques will solve my problems. Perhaps it could also provide relevant alternatives to using SUMPRODUCT and Array Formulae.
regards
Geoffrey Howell
-
WSStumped
AskWoody LoungerFebruary 26, 2005 at 1:35 pm #931332No, Geoffrey, you are not too late. I am frankly surprised you were able to dig out this post as its a few weeks old! I have no personal experience of using the DCOUNT or other functions you mentioned. While my (relatively simple) needs were met with the previous replies, I will keep your suggestion in mind and it just might come in useful sometime in the future. Thanks for your post.
-
WSunkamunka
AskWoody LoungerFebruary 26, 2005 at 2:32 pm #931340> I am frankly surprised you were able to dig out this post as its a few weeks old
If you put key word(s) into our Search function (at the top of every page in the Lounge), you will be able to find very specific results among >456,000 posts – stretching back to when this version of the Lounge went live in December 2000.
“Search” is our most under-utilised resource.
HTH
-
-
-
-
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Digital TV Antenna Recommendation
by
Win7and10
14 minutes ago -
Server 2019 Domain Controllers broken by updates
by
MP Support
5 hours, 9 minutes ago -
Google won’t remove 3rd party cookies in Chrome as promised
by
Alex5723
6 hours, 48 minutes ago -
Microsoft Manager Says macOS Is Better Than Windows 11
by
Alex5723
10 hours ago -
Outlook (NEW) Getting really Pushy
by
RetiredGeek
3 hours, 9 minutes ago -
Steps to take before updating to 24H2
by
Susan Bradley
51 minutes ago -
Which Web browser is the most secure for 2025?
by
B. Livingston
1 hour, 55 minutes ago -
Replacing Skype
by
Peter Deegan
22 minutes ago -
FileOptimizer — Over 90 tools working together to squish your files
by
Deanna McElveen
3 hours, 52 minutes ago -
Excel Macro — ask for filename to be saved
by
nhsj
12 hours, 19 minutes ago -
Trying to backup Win 10 computer to iCloud
by
SheltieMom
4 hours, 47 minutes ago -
Windows 11 Insider Preview build 26200.5570 released to DEV
by
joep517
2 days, 9 hours ago -
Windows 11 Insider Preview build 26120.3941 (24H2) released to BETA
by
joep517
2 days, 11 hours ago -
Windows 11 Insider Preview Build 22635.5305 (23H2) released to BETA
by
joep517
2 days, 11 hours ago -
No April cumulative update for Win 11 23H2?
by
Peobody
23 hours, 46 minutes ago -
AugLoop.All (TEST Augmentation Loop MSIT)
by
LarryK
2 days, 12 hours ago -
Boot Sequence for Dell Optiplex 7070 Tower
by
Serge Carniol
3 days, 3 hours ago -
OTT Upgrade Windows 11 to 24H2 on Unsupported Hardware
by
bbearren
3 days, 6 hours ago -
Inetpub can be tricked
by
Susan Bradley
1 day, 14 hours ago -
How merge Outlook 2016 .pst file w/into newly created Outlook 2024 install .pst?
by
Tex265
2 days ago -
FBI 2024 Internet Crime Report
by
Alex5723
3 days, 10 hours ago -
Perplexity CEO says its browser will track everything users do online
by
Alex5723
19 hours, 47 minutes ago -
Login issues with Windows Hello
by
CWBillow
3 days, 21 hours ago -
How to get into a manual setup screen in 2024 Outlook classic?
by
Tex265
3 days, 9 hours ago -
Linux : ARMO rootkit “Curing”
by
Alex5723
4 days, 9 hours ago -
Employee monitoring app leaks 21 million screenshots in real time
by
Alex5723
4 days, 9 hours ago -
Google AI is now hallucinating idioms
by
Alex5723
4 days, 9 hours ago -
april update
by
69800
2 days, 14 hours ago -
Windows 11 Insider Preview build 27842 released to Canary
by
joep517
4 days, 10 hours ago -
Quick Fix for Slowing File Explorer
by
Drcard:))
4 days, 11 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.