Formula for calculating count based on date or month ranges

Pancakey

New Member
Joined
Sep 27, 2023
Messages
22
Office Version
  1. 2021
Platform
  1. Windows
Hello,

I am a beginner using Excel formulas and I am trying to count the number of cells (column C of the first image) that falls within each month of the year (column I, see the second image).

I know the formula below is incorrect, and I am trying to figure out how the date range for each month can fall within it with a number count as the result.
=COUNTIFS('Purchase Order'!C:C,">=6/31/2023",'Purchase Order'!C:C,"<=6/1/2023")

For example, C4:C6 in the first screenshot has the dates 11/28/23, so I want a formula in column I, PO Month, see the second screenshot, to identify these date ranges within the month of November and so forth.

1701401507139.png


Additionally, is there anything different for the formula if I want to count the dollar value of a column that falls under a specific month for POs that has been issued?
1701401560890.png
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Demo of one way:
Book1
BCDEFGHIJK
3#date$PO Month#$
4111/28/23$10.00September 230$0.00
5211/28/23$10.00October 230$0.00
6311/28/23$10.00November 235$50.00
7411/28/23$10.00December 234$40.00
8511/28/23$10.00January 240$0.00
9612/1/23$10.00
10712/1/23$10.00
11812/1/23$10.00
12912/1/23$10.00
Sheet2
Cell Formulas
RangeFormula
J4:J8J4=SUMPRODUCT(--(TEXT($C$4:$C$12,"mmmm yy")=TEXT(I4,"mmmm yy")))
K4:K8K4=SUMPRODUCT(--(TEXT($C$4:$C$12,"mmmm yy")=TEXT(I4,"mmmm yy")),$D$4:$D$12)
 
Upvote 0
The formula seems to work, however it doesn't seem to work on my table for some reason.

In your example:
Column C, I have a formula in the cell. See below sample. I am not sure if this is affecting the sumproduct formula.
=VLOOKUP(E7,'PO Line Data UPD 11-30-23'!$1:$1048576,5,FALSE)

1701411749573.png


On a separate note, if I wanted to find out the total amount paid vs unpaid in one separate cell each (paid and unpaid) based on the total POs issued or cells entered, how would I do so?

See above image between columns K to M. Would we use a sumif formula?
 
Upvote 0
I forgot to mention in your column I, I have the below formula entered. I am wondering if this formula is also affecting the sum formula.

=DATE(YEAR(StartDate),MONTH(StartDate),1)
 
Upvote 0
Hello, I have three tabs in my worksheet, please see below for the first tab.

FIRST TAB: DASHBOARD
Note: Currently working on the formulas for the tables...the information I want to populate are on this tab.

Cell Formulas
RangeFormula
B11B11=W17
C11C11=W4
B16B16=X17
C16C16=X20
W16W16="ISSUED ("&W17&")"
X16X16="PAID ("&X17&") - "&TEXT(Y17,"0.0%")
W17W17=SUM(J24:J35)
X17X17=SUM(J24:J35)
Y17Y17=IFERROR(#REF!/#REF!,0)
X19X19="PAID"&" - "&TEXT(Y20,"0.0%")
W20W20=SUM(K24:K35)
X20X20=SUM(M24:M35)
Y20Y20=IFERROR(X20/W20,0)
B21:C21B21=B11-B16
V23:V34V23=I24
W23:W34W23=K24
X23:X34X23=M24
Y23:Y34Y23=P24
I24I24=DATE(YEAR(StartDate),MONTH(StartDate),1)
J24:J35J24=SUMPRODUCT(--(TEXT('Purchase Order'!$C:$C,"mmmm yy")=TEXT(I24,"mmmm yy")))
K24:K35K24=SUMPRODUCT(--(TEXT('Purchase Order'!$C:$C,"mmmm yy")=TEXT(I24,"mmmm yy")),'Purchase Order'!$F:$F)
L24:L35L24=COUNTIFS('Purchase Order'!R:R,">=0",'Purchase Order'!C:C,">="&I24,'Purchase Order'!C:C,"<="&EOMONTH(I24,0))
M24:M35M24=SUMIFS('Purchase Order'!R:R,'Purchase Order'!C:C,">="&I24,'Purchase Order'!C:C,"<="&EOMONTH(I24,0))
N24:O35N24=IFERROR(L24/J24,0)
P24:P35P24=IF(K24<>0,IFERROR(SUMIFS('Purchase Order'!#REF!,'Purchase Order'!#REF!,">=0",'Purchase Order'!C:C,">="&I24,'Purchase Order'!C:C,"<="&EOMONTH(I24,0))/L24,0),NA())
I25:I35I25=EOMONTH(I24,0)+1
G23G23=SUM(COUNTIF('Purchase Order'!I:I,"Issued"))
G24G24=SUM(COUNTIF('Purchase Order'!I:I,"Not Sent"))
G25G25=SUM(COUNTIF('Purchase Order'!Q:Q,"Unpaid"))
G27G27=SUM(COUNTIF('Purchase Order'!Q:Q,"Paid"))
G28G28=SUM(COUNTIF('Purchase Order'!K:K,"Completed"))
G29G29=SUM(COUNTIF('Purchase Order'!I:I,"Cancelled"))
G30G30=SUM(G23:G24,G29)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
P24:P35Expression=ISNA(P24)textNO
 
Upvote 0
My data is too long, so I shorten this list to 20 lines of data.

SECOND TAB: PURCHASE ORDER
PO Status Tracker.xlsx
ABCDEFGHIJKLMNOPQR
1
2NoPO DatePO #Supplier NamePurchase Order Total Requester Name PO Transmission Status PO IssuedPO AcknowledgedPO StatusDelivered DateOrder NotesInvoicedNet Terms If Paid (T/F) Payment Status Total Invoiced
3
4 111/30/235096Target35.96 Claire Awaiting Online Purchase Not Sent - No Prepayment FALSE Unpaid -
5 211/30/235095Home Depot35.96 Ken Awaiting Online Purchase Not Sent - No Prepayment FALSE Unpaid -
6 311/30/235094Swagelok35.96 Matthew Awaiting Online Purchase Not Sent - No Net 30 FALSE Unpaid -
7 411/30/235093Sigma-Aldrich35.96 Anna Awaiting Online Purchase Not Sent - No Net 30 FALSE Unpaid -
8 511/30/235092Target59.97 Claire Sent via cxml Issued - No Prepayment FALSE Unpaid -
9 611/30/235091Home Depot59.97 Ken Sent via cxml Issued - No Prepayment FALSE Unpaid -
10 711/30/235090Swagelok12.05 Matthew Sent via cxml Issued - No Net 30 FALSE Unpaid -
11 811/30/235089Sigma-Aldrich8.99 Anna Sent via cxml Issued - No Net 30 FALSE Unpaid -
12 911/30/235088Target170.35 Claire Sent Manually Issued - No Prepayment FALSE Unpaid -
13 1011/30/235087Home Depot48.28 Ken Sent via cxml Issued - No Prepayment FALSE Unpaid -
14 1111/30/235086Swagelok48.28 Matthew Sent via cxml Issued - No Net 30 FALSE Unpaid -
15 1211/29/235085Sigma-Aldrich177.99 Anna Sent Manually Issued - No Net 30 FALSE Unpaid -
16 1311/29/235084Target1800.00 Claire Pending Manual Not Sent - No Prepayment FALSE Unpaid -
17 1411/29/235083Home Depot808.00 Ken Pending Manual Not Sent - No Prepayment FALSE Unpaid -
18 1511/29/235082Swagelok26.97 Matthew Awaiting Online Purchase Not Sent - No Net 30 FALSE Unpaid -
19 1611/29/235081Sigma-Aldrich108.00 Anna Sent via cxml Issued - No Net 30 FALSE Unpaid -
20 1711/29/235080Target21.99 Claire Sent via cxml Issued - No Prepayment FALSE Unpaid -
21 1811/29/235079Home Depot47.86 Ken Sent via cxml Issued - No Prepayment FALSE Unpaid -
22 1911/29/235078Swagelok141.35 Matthew Sent Manually Issued - No Net 30 FALSE Unpaid -
23 2011/29/235077Sigma-Aldrich141.35 Anna Sent Manually Issued - No Net 30 FALSE Unpaid -
Purchase Order
Cell Formulas
RangeFormula
H4:H23H4=IFNA(VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,3,FALSE),"")
I4I4=IF(OR(H4="Sent via cxml",H4="Sent via Email",H4="Sent Manually"),"Sent",IF(OR(H4="Not Sent",H4="Awaiting Online Purchase",H4="Pending Manual",H4=""),"Not Sent",(IF(H4="Pending Manual Cancel","Cancelled",""))))
I5:I23I5=IF(OR(H5="Sent via cxml",H5="Sent via Email",H5="Sent Manually"),"Issued",IF(OR(H5="Not Sent",H5="Awaiting Online Purchase",H5="Pending Manual",H5=""),"Not Sent",(IF(H5="Pending Manual Cancel","Cancelled",""))))
K4:K23K4=IF(AND(L4<>"",Q4="Paid"),"Completed","")
L4:L23L4=IFNA(VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,11,FALSE),"")
N4:N23N4=IFNA(IF(R4="*","Yes","No"),"")
O4:O23O4=IFNA(VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,9,FALSE),"")
P4:P23P4=IFNA(VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,12,FALSE),0)
Q4:Q23Q4=IF(P4=TRUE,"Paid","Unpaid")
R4:R23R4=IFNA(VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,8,FALSE),"")
A4:A23A4=IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,IF(#REF!<>"",#REF!,0))))))))))
C4:C23C4=VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,2,FALSE)
F4:F23F4=VLOOKUP(D4,'PO Line Data UPD 11-28-23'!$1:$1048576,7,FALSE)
Named Ranges
NameRefers ToCells
InvoiceList='Purchase Order'!$D$4:$D$5003R4, O4:P4, L4, H4, F4, C4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
K4:K4001Cell Valuecontains "Completed"textNO
R4:R4001Cell Valuecontains "Not Sent"textNO
R4:R4001Cell Valuecontains "Awaiting Online Purchase"textNO
R4:R4001Cell Valuecontains "Pending Manual"textNO
R4:R4001Cellcontains a blank value textNO
H4:H5003Cell Valuecontains "Not Sent"textNO
H4:H5003Cell Valuecontains "Awaiting Online Purchase"textNO
H4:H5003Cell Valuecontains "Pending Manual"textNO
J4:J5003Cell Valuecontains "No"textNO
J4:J5003Cell Valuecontains "Yes"textNO
P4:R4,P5:Q5003,R5:R4001,C4:O5003Expression=AND(#REF!<TODAY(),#REF!="Unpaid")textNO
H4:H5003Cellcontains a blank value textNO
Cells with Data Validation
CellAllowCriteria
J4:J23ListYes, No
M4:M23ListAwaiting Response from Supplier, Order Hold - Pending Payment, Followed-up with the Supplier, Order Lost/Missing, Payment Issue, PO Hold, Write Off
 
Upvote 0
I am not sure if this is helpful, but this is the third sample data tab.

THIRD TAB: PO DATA
PO Status Tracker.xlsx
ABCDEFGHIJKL
1PO Number Order Date Order Transmission Status (Header)SupplierItemOrder Status (Header)Order Total Total InvoicedPayment TermRequested By (Header)Received DatePaid
2509611/30/23Awaiting Online PurchaseTargetSample ItemIssued35.96Prepayment Claire FALSE
3509511/30/23Awaiting Online PurchaseHome DepotSample ItemIssued35.96Prepayment Ken FALSE
4509411/30/23Awaiting Online PurchaseSwagelokSample ItemIssued35.96Net 30 Matthew FALSE
5509311/30/23Awaiting Online PurchaseSigma-AldrichSample ItemIssued35.96Net 30 Anna FALSE
6509211/30/23Sent via cxmlTargetSample ItemIssued59.97Prepayment Claire FALSE
7509111/30/23Sent via cxmlHome DepotSample ItemIssued59.97Prepayment Ken FALSE
8509011/30/23Sent via cxmlSwagelokSample ItemIssued12.05Net 30 Matthew FALSE
9508911/30/23Sent via cxmlSigma-AldrichSample ItemIssued8.99Net 30 Anna FALSE
10508811/30/23Sent ManuallyTargetSample ItemIssued170.35Prepayment Claire FALSE
11508711/30/23Sent via cxmlHome DepotSample ItemIssued48.28Prepayment Ken FALSE
12508611/30/23Sent via cxmlSwagelokSample ItemIssued48.28Net 30 Matthew FALSE
13508511/29/23Sent ManuallySigma-AldrichSample ItemIssued177.99Net 30 Anna FALSE
14508411/29/23Pending ManualTargetSample ItemIssued1800.00Prepayment Claire FALSE
15508311/29/23Pending ManualHome DepotSample ItemIssued808.00Prepayment Ken FALSE
16508211/29/23Awaiting Online PurchaseSwagelokSample ItemIssued26.97Net 30 Matthew FALSE
17508111/29/23Sent via cxmlSigma-AldrichSample ItemIssued108.00Net 30 Anna FALSE
18508011/29/23Sent via cxmlTargetSample ItemIssued21.99Prepayment Claire FALSE
19507911/29/23Sent via cxmlHome DepotSample ItemIssued47.86Prepayment Ken FALSE
20507811/29/23Sent ManuallySwagelokSample ItemIssued141.35Net 30 Matthew FALSE
PO Line Data UPD 11-28-23
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J2:J100Expression=AND(#REF!<TODAY(),#REF!="Unpaid")textNO
D2:D100Expression=AND(#REF!<TODAY(),#REF!="Unpaid")textNO
A2:A98Expression=AND(#REF!<TODAY(),#REF!="Unpaid")textNO
 
Upvote 0

Forum statistics

Threads
1,215,071
Messages
6,122,964
Members
449,094
Latest member
Anshu121

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