简体   繁体   中英

excel - countif and weeknum

Overview

  • would like to use countif and weeknum to count how many dates late on a specific week

Data google doc> https://docs.google.com/spreadsheets/d/16eTH7k7oNJcILEL8qCNKIBbg4EvkKAaRYtbN2PhfXCg/edit#gid=0

  • Column 1, has dates 1/12/17(2) 1/3/17(1) 1/1/16(1)
  • Column 2, has weeknum 2, 1, 1

Tried formulas:

  • COUNTIF(WEEKNUM(A2:A9),A2:A9=1)
  • COUNTIF(A2:A9,WEEKNUM(A2:A9)=1)

Result

  • should be 2 but get 0

Question:

  • what am i doing wrong?

You cannot use WEEKNUM with COUNTIF, without a helper column to do the WEEKNUM.

Use SUMPRODUCT instead:

=SUMPRODUCT(--(WEEKNUM(A2:A9)=1))

Or since you already have the helper column in Column B, you can use COUNTIF on that:

=COUNTIF(B:B,1)

Question:

  • what am i doing wrong?

The wrong syntax for COUNTIF .

Scott is right.

You can either use SUMPRODUCT directly or use a helper column beside and use a COUNTIF .

=SUMPRODUCT(--(WEEKNUM(A2:A9)=1))

=COUNTIF(B:B,1)

The reason to have -- is that SUMPRODUCT ignores non-numeric entries. Thus we need to transfer Ture/False to 1/0.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM