Countifs based on range defined by date

Deven09

New Member
Joined
Jun 28, 2023
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
I have data sheet format as below.

A B C
1 Name | 06/01/2023 | 06/02/2023 and so on for all dates.
2 Sam 2 3
3 Sam 0 2
4 Dan 2 3
5 Sam 4 0
6 Ram 3 1

I need output as below. Need countifs formula which will take counts with conditions as per date entered in first row. If the dates are changed then the count should be taken from the respective date column of the data sheet.

A B C
1 06/01/2023 | 06/01/2023 and so on for all dates.
2 Name count of records<3 | count of records Between 3 to 5
3 Sam <Formula> =2 | <Formula> =1
4 Ram <Formula> = 0 | <Formula> = 1
5 Dan <Formula> = 1 | <Formula> =0
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Refer attached image.
 

Attachments

  • example.JPG
    example.JPG
    46.5 KB · Views: 15
Upvote 0
Is this what you mean?

Book1
ABCDEFG
1NameDate 1Date 2Result Date 1Date 2
2Sam23Sam2 | 12 | 1
3Sam02Ram0 | 11 | 0
4Dan23Dan1 | 00 | 1
5Sam40
6Ram31
Sheet2
Cell Formulas
RangeFormula
F2:G4F2=COUNTIFS($A$2:$A$6,$E2,B$2:B$6,"<3")&" | "&COUNTIFS($A$2:$A$6,$E2,B$2:B$6,">=3",B$2:B$6,"<=5")
 
Upvote 0
BTW: your posted picture is small enough to replicate. In the future, especially with large samples of data, please use XL2BB to post sample data and expected results.
 
Upvote 0
So, how about this modification?

Book1
ABCDEFGHI
1NameDate 1Date 2Result Date 1Date 2
2Sam23Sam2121
3Sam02Ram0110
4Dan23Dan1001
5Sam40
6Ram31
Sheet2
Cell Formulas
RangeFormula
F2:F4F2=COUNTIFS($A$2:$A$6,$E2,B$2:B$6,"<3")
G2:G4G2=COUNTIFS($A$2:$A$6,$E2,B$2:B$6,">=3",B$2:B$6,"<=5")
H2:H4H2=COUNTIFS($A$2:$A$6,$E2,C$2:C$6,"<3")
I2:I4I2=COUNTIFS($A$2:$A$6,$E2,C$2:C$6,">=3",C$2:C$6,"<=5")
 
Upvote 0
So, how about this modification?

Book1
ABCDEFGHI
1NameDate 1Date 2Result Date 1Date 2
2Sam23Sam2121
3Sam02Ram0110
4Dan23Dan1001
5Sam40
6Ram31
Sheet2
Cell Formulas
RangeFormula
F2:F4F2=COUNTIFS($A$2:$A$6,$E2,B$2:B$6,"<3")
G2:G4G2=COUNTIFS($A$2:$A$6,$E2,B$2:B$6,">=3",B$2:B$6,"<=5")
H2:H4H2=COUNTIFS($A$2:$A$6,$E2,C$2:C$6,"<3")
I2:I4I2=COUNTIFS($A$2:$A$6,$E2,C$2:C$6,">=3",C$2:C$6,"<=5")
Thanks but the data will be for entire month, with this solution, I need to revise formula for each date. Is it possible to have a formula for one date(Column F and Column G) which can be simply copy pasted to another dates. One solution I was thinking of to design a formula which will decide the range based on date mentioned in the headings and accordingly populate counts based on dates.
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGHI
1Name01/06/202302/06/2023Result 01/06/202301/06/202302/06/202302/06/2023
2Sam23Sam2121
3Sam02Ram0110
4Dan23Dan1001
5Sam40
6Ram31
7
Sheet4
Cell Formulas
RangeFormula
F2:F4,H2:H4F2=SUMPRODUCT(($A$2:$A$6=$E2)*($B$1:$C$1=F$1)*($B$2:$C$6<3))
G2:G4,I2:I4G2=SUMPRODUCT(($A$2:$A$6=$E2)*($B$1:$C$1=G$1)*($B$2:$C$6>=3)*($B$2:$C$6<=5))
 
Upvote 0
How about
Fluff.xlsm
ABCDEFGHI
1Name01/06/202302/06/2023Result 01/06/202301/06/202302/06/202302/06/2023
2Sam23Sam2121
3Sam02Ram0110
4Dan23Dan1001
5Sam40
6Ram31
7
Sheet4
Cell Formulas
RangeFormula
F2:F4,H2:H4F2=SUMPRODUCT(($A$2:$A$6=$E2)*($B$1:$C$1=F$1)*($B$2:$C$6<3))
G2:G4,I2:I4G2=SUMPRODUCT(($A$2:$A$6=$E2)*($B$1:$C$1=G$1)*($B$2:$C$6>=3)*($B$2:$C$6<=5))
Perfect...!!!! You are a great help..!! I was struggling with this.. Thanks a lot..!!!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,200
Members
453,022
Latest member
RobertV1609

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