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. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
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, 1 month 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
-
Uninstalr Updates
by
jv16
6 hours, 56 minutes ago -
Apple zero days for April
by
Susan Bradley
2 hours, 13 minutes ago -
CVE program gets last-minute funding from CISA – and maybe a new home
by
Nibbled To Death By Ducks
7 hours, 44 minutes ago -
Whistleblower describes DOGE IT dept rumpus at America’s labor watchdog
by
Nibbled To Death By Ducks
19 hours, 33 minutes ago -
Seeing BSOD’s on 24H2?
by
Susan Bradley
2 hours, 28 minutes ago -
TUT For Private Llama LLM, Local Installation and Isolated from the Internet.
by
bbearren
9 hours, 57 minutes ago -
Upgrade from Windows 10 to 11
by
Holdsworth8
1 day, 4 hours ago -
Microsoft : AI-powered deception: Emerging fraud threats and countermeasures
by
Alex5723
1 day, 7 hours ago -
0patch
by
WSjcgc50
8 hours, 2 minutes ago -
Devices might encounter blue screen exception with the recent Windows updates
by
Susan Bradley
1 day ago -
Windows 11 Insider Preview Build 22631.5261 (23H2) released to Release Preview
by
joep517
1 day, 10 hours ago -
Problem opening image attachments
by
RobertG
1 day, 11 hours ago -
advice for setting up a new windows computer
by
routtco1001
2 days, 2 hours ago -
It’s Identity Theft Day!
by
Susan Bradley
1 day, 6 hours ago -
Android 15 require minimum 32GB of storage
by
Alex5723
2 days, 7 hours ago -
Mac Mini 2018, iPhone 6s 2015 Are Now Vintage
by
Alex5723
2 days, 7 hours ago -
Hertz says hackers stole customer credit card and driver’s license data
by
Alex5723
2 days, 7 hours ago -
Firefox became sluggish
by
Rick Corbett
10 minutes ago -
Windows 10 Build 19045.5794 (22H2) to Release Preview Channel
by
joep517
2 days, 11 hours ago -
Windows 11 Insider Preview Build 22635.5235 (23H2) released to BETA
by
joep517
2 days, 12 hours ago -
A Funny Thing Happened on the Way to the Forum
by
bbearren
1 day, 9 hours ago -
Download speeds only 0.3Mbps after 24H2 upgrade on WiFi and Ethernet
by
John
6 hours, 29 minutes ago -
T-Mobile 5G Wireless Internet
by
WSmmi16
1 day, 10 hours ago -
Clock missing above calendar in Windows 10
by
WSCape Sand
1 day, 11 hours ago -
Formula to Calculate Q1, Q2, Q3, or Q4 of the Year?
by
WSJon5
3 days, 3 hours ago -
The time has come for AI-generated art
by
Catherine Barrett
2 days, 7 hours ago -
Hackers are using two-factor authentication to infect you
by
B. Livingston
2 days, 16 hours ago -
23 and you
by
Max Stul Oppenheimer
3 days ago -
April’s deluge of patches
by
Susan Bradley
1 day, 3 hours ago -
Windows 11 Windows Updater question
by
Tex265
17 hours, 51 minutes 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.