Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Conditional function with count

Hi,

I tried to make a formula that count if two statements are true. For example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is 7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that is
25.

Then, I tried to combined this 2 formulas for using a conditional statement
AND, because I want that the formula count when this 2 statements are true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,624
Default Conditional function with count

One way:

=SUMPRODUCT(--(M!E2:E37={"P,"Y"}))

See http://www.mcgimpsey.com/excel/doubleneg.html for an explanation of
the "--"



In article ,
anamarie30 wrote:

Hi,

I tried to make a formula that count if two statements are true. For example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is 7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that is
25.

Then, I tried to combined this 2 formulas for using a conditional statement
AND, because I want that the formula count when this 2 statements are true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,574
Default Conditional function with count

You're using the COUNT function, which counts numbers, not logical values.
To coerce the COUNTIF function into returning 1s for TRUE values and 0 for
FALSE values, which, in turn, will allow you to use the COUNT function, try:

=COUNT(AND(--(COUNTIF(M!E2:E37, "P")),--(COUNTIF(M!L2:L37, "Y"))))

The -- symbol coerces logicals (TRUE and FALSE) into 1 and 0 respectively.

Dave

--
A hint to posters: Specific, detailed questions are more likely to be
answered than questions that provide no detail about your problem.


"anamarie30" wrote:

Hi,

I tried to make a formula that count if two statements are true. For example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is 7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that is
25.

Then, I tried to combined this 2 formulas for using a conditional statement
AND, because I want that the formula count when this 2 statements are true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 492
Default Conditional function with count

Try
=SUMPRODUCT(--(M!E2:E37="P"),--(M!L2:L37="Y"))
Regards,
Alan.
"anamarie30" wrote in message
...
Hi,

I tried to make a formula that count if two statements are true. For
example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is
7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that
is
25.

Then, I tried to combined this 2 formulas for using a conditional
statement
AND, because I want that the formula count when this 2 statements are
true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks


  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 26
Default Conditional function with count

Thanks for your help. It works.

"Alan" wrote:

Try
=SUMPRODUCT(--(M!E2:E37="P"),--(M!L2:L37="Y"))
Regards,
Alan.
"anamarie30" wrote in message
...
Hi,

I tried to make a formula that count if two statements are true. For
example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is
7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that
is
25.

Then, I tried to combined this 2 formulas for using a conditional
statement
AND, because I want that the formula count when this 2 statements are
true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks





  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default Conditional function with count

Your first COUNTIF returns 7; 7 is a non-zero number and hence is regarded
as TRUE. Similarly your second COUNTIF would be regarded as TRUE.
Your AND condition is ANDing two TRUEs and thus gives TRUE.
Your final expression is effectively =COUNT(AND(TRUE,TRUE)), so I would
expect it to return 1.
--
David Biddulph

"anamarie30" wrote in message
...
Hi,

I tried to make a formula that count if two statements are true. For
example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is
7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that
is
25.

Then, I tried to combined this 2 formulas for using a conditional
statement
AND, because I want that the formula count when this 2 statements are
true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Conditional function with count

Xl 2007

=COUNTIFS(M!E2:E37,"P",M!L2:L37,"Y")


"anamarie30" wrote:

Hi,

I tried to make a formula that count if two statements are true. For example,
=COUNTIF(M!E2:E37,"P") This formula give me the correct number that is 7.
=COUNTIF(M!L2:L37,"Y") This formula give me the correct number that is
25.

Then, I tried to combined this 2 formulas for using a conditional statement
AND, because I want that the formula count when this 2 statements are true.
=AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))) Result: True

Then, I tried to make the count if this condition are True, but the count
give a wrong number. The formula that I tried is
=COUNT(AND((COUNTIF(M!E2:E37, "P")), (COUNTIF(M!L2:L37, "Y"))))

Somebody can help me.

Thanks

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
What's the best way to count conditional formats? KeefatCWS Excel Discussion (Misc queries) 3 August 31st 06 06:31 PM
Conditional Count 2 Columns rileym Excel Worksheet Functions 1 August 23rd 06 03:54 AM
Conditional Count Ralph Excel Worksheet Functions 2 December 1st 05 06:27 PM
Using Count function with a conditional range Phil Excel Worksheet Functions 3 September 25th 05 11:52 AM
conditional count Karen Excel Worksheet Functions 1 August 11th 05 11:53 PM


All times are GMT +1. The time now is 01:13 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"