Conditional IF's

lbgolferga

New Member
Joined
Mar 5, 2002
Messages
5
I am trying to count the number of times a conditional value occurs in a spreadsheet. I would like to check column A:1-end for a value "AAA". If true then check column D, same row for one of 3 values. If any are true add 1 to the total. I have tried this:
=sum(if(a1:A100="aaa",if(d1:d100="LB",1,0),0)) as an array function and it works but only for one conditional occurance. Can I check for all three with one statment? I.E. If col-a="aaa" and (col-d = ("LB" or "PR" or "MG") , add 1 to total.
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
On 2002-03-06 10:27, lbgolferga wrote:
I am trying to count the number of times a conditional value occurs in a spreadsheet. I would like to check column A:1-end for a value "AAA". If true then check column D, same row for one of 3 values. If any are true add 1 to the total. I have tried this:
=sum(if(a1:A100="aaa",if(d1:d100="LB",1,0),0)) as an array function and it works but only for one conditional occurance. Can I check for all three with one statment? I.E. If col-a="aaa" and (col-d = ("LB" or "PR" or "MG") , add 1 to total.

Try:

=SUMPRODUCT((A2:A4="aaa")*(D2:D4={"LB","PR","MG"}))
 
Upvote 0
On 2002-03-06 12:01, Aladin Akyurek wrote:
On 2002-03-06 10:27, lbgolferga wrote:
I am trying to count the number of times a conditional value occurs in a spreadsheet. I would like to check column A:1-end for a value "AAA". If true then check column D, same row for one of 3 values. If any are true add 1 to the total. I have tried this:
=sum(if(a1:A100="aaa",if(d1:d100="LB",1,0),0)) as an array function and it works but only for one conditional occurance. Can I check for all three with one statment? I.E. If col-a="aaa" and (col-d = ("LB" or "PR" or "MG") , add 1 to total.

Try:

=SUMPRODUCT((A2:A4="aaa")*(D2:D4={"LB","PR","MG"}))

This solution worked beautifully, Thank You. Now one additional twist. In checking Column A: could you also check for multiple values? I.E. check for "AAA" or "BBB" then if true check check Column D: for ("LB","PR","MG"). I tried plugging it in the formula as an array on Column a but it did not seem to work.
 
Upvote 0
On 2002-03-06 15:22, lbgolferga wrote:
On 2002-03-06 12:01, Aladin Akyurek wrote:
On 2002-03-06 10:27, lbgolferga wrote:
I am trying to count the number of times a conditional value occurs in a spreadsheet. I would like to check column A:1-end for a value "AAA". If true then check column D, same row for one of 3 values. If any are true add 1 to the total. I have tried this:
=sum(if(a1:A100="aaa",if(d1:d100="LB",1,0),0)) as an array function and it works but only for one conditional occurance. Can I check for all three with one statment? I.E. If col-a="aaa" and (col-d = ("LB" or "PR" or "MG") , add 1 to total.

Try:

=SUMPRODUCT((A2:A4="aaa")*(D2:D4={"LB","PR","MG"}))

This solution worked beautifully, Thank You. Now one additional twist. In checking Column A: could you also check for multiple values? I.E. check for "AAA" or "BBB" then if true check check Column D: for ("LB","PR","MG"). I tried plugging it in the formula as an array on Column a but it did not seem to work.

That's right: You need to "fix" one set of values against to the other set of values with which you want to do OR'ing.

=SUMPRODUCT(((A2:A4="aaa")*(D2:D4={"LB","PR","MG"})+(A2:A4="X")*(D2:D4={"LB","PR","MG"})))

Aladin
 
Upvote 0
On 2002-03-06 21:51, Aladin Akyurek wrote:
On 2002-03-06 15:22, lbgolferga wrote:
On 2002-03-06 12:01, Aladin Akyurek wrote:
On 2002-03-06 10:27, lbgolferga wrote:
I am trying to count the number of times a conditional value occurs in a spreadsheet. I would like to check column A:1-end for a value "AAA". If true then check column D, same row for one of 3 values. If any are true add 1 to the total. I have tried this:
=sum(if(a1:A100="aaa",if(d1:d100="LB",1,0),0)) as an array function and it works but only for one conditional occurance. Can I check for all three with one statment? I.E. If col-a="aaa" and (col-d = ("LB" or "PR" or "MG") , add 1 to total.

Try:

=SUMPRODUCT((A2:A4="aaa")*(D2:D4={"LB","PR","MG"}))

This solution worked beautifully, Thank You. Now one additional twist. In checking Column A: could you also check for multiple values? I.E. check for "AAA" or "BBB" then if true check check Column D: for ("LB","PR","MG"). I tried plugging it in the formula as an array on Column a but it did not seem to work.

That's right: You need to "fix" one set of values against to the other set of values with which you want to do OR'ing.

=SUMPRODUCT(((A2:A4="aaa")*(D2:D4={"LB","PR","MG"})+(A2:A4="X")*(D2:D4={"LB","PR","MG"})))

Aladin
Thank You again, it works great.

LB
 
Upvote 0

Forum statistics

Threads
1,223,406
Messages
6,171,927
Members
452,434
Latest member
NUC_N_FUTS2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top