Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

date - Excel Countif using month and letter as Criteria's

I have a list of sales data that includes the date of the sale and also a sales type code. I'm trying to use COUNTIFS to count how many sales of a specific type there were during each month .

So for example:

Date.                  Sales Type Code
10/01/2014.                 S
12/01/2014.                 S
15/01/2014.                 O
18/01/2014.                 S
02/02/2014.                 O
08/02/2014.                 S

Would give me the following results:

Code S

January -       3    
February -      1

Code O

January -       1
February -      1

I have the formula

COUNTIFS('SALES LEDGER'!A:A,F2,'SALES LEDGER'!C:C,"<"&EOMONTH('MONTH Sales by Sales Type'!$C$1,0)+1)

Where A:A is the list of Sales Type Codes, F2 is the code I want to count, C:C is the list of dates and C1 is the first of the month I want to count (ie. 01/01/2014).

This works fine for January, giving me the expected result. But when I change C1 to 01/02/2014, it counts January and February together, rather than just February.

If anyone has any suggestions it would be appreciated!

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your COUNTIFS formula specifies an end date but no start date, if you want to count for a specific month and year (based on C1) you need another criterion to specify the start date using C1, i.e.

=COUNTIFS('SALES LEDGER'!A:A,F2,'SALES LEDGER'!C:C,"<"&EOMONTH('MONTH Sales by Sales Type'!$C$1,0)+1,'SALES LEDGER'!C:C,">="&'MONTH Sales by Sales Type'!$C$1)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...