Getting a count

SandsB

Well-known Member
Joined
Feb 13, 2007
Messages
705
Office Version
  1. 365
Platform
  1. Windows
Sheet1 column A contains dates, Column B contains one of 5 text strings. There may be 100 rows for 2/22/23, then 20 rows for 2/23/23, then 50 rows for 2/34/23, etc.
I need cell A1 in Sheet2 to look at Sheet1 and give me the count of all records for 2/22/23 that contain "text string 1". And B1 is the same for "text string 2."
Then A2 and B2 are the same things for 2/23/23
Then A3 and B3 are etc.

So A1 in Sheet2 should be a formula that reads "Look at all the rows in Sheet 1 that contain 2/22/23 in column A and tell me how many of those rows have "text string 1" in column B.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I'm thinking a Countif but I can't see a way to do that based on date
 
Upvote 0
here are two ways:
You would need to update sheet/cell references.
Mr Excel 8.xlsm
ABCDEFGHIJ
1DateTextTextString 1TextString 1
22023-02-19TextString 12023-02-1922023-02-192
32023-02-19TextString 22023-02-2022023-02-202
42023-02-19TextString 32023-02-2102023-02-210
52023-02-19TextString 4
62023-02-19TextString 5
72023-02-19TextString 1
82023-02-19TextString 2
92023-02-19TextString 3
102023-02-19TextString 4
112023-02-19TextString 5
122023-02-20TextString 1
132023-02-20TextString 2
142023-02-20TextString 3
152023-02-20TextString 4
162023-02-20TextString 5
172023-02-20TextString 1
182023-02-21TextString 2
192023-02-21TextString 3
202023-02-21TextString 4
21
Sheet11
Cell Formulas
RangeFormula
F2:F4F2=COUNTIFS($A$2:$A$20,$E2,$B$2:$B$20,F$1)
I2:I4I2=SUM((--(I$1=$B$2:$B$20))*(--($H2=$A$2:$A$20)))
 
Upvote 0
A little better example of the same...
Mr Excel 8.xlsm
ABCDEFGHI
1DateTextTextString 1TextString 2TextString 1TextString 2
22023-02-19TextString 12023-02-19222023-02-1922
32023-02-19TextString 22023-02-20212023-02-2021
42023-02-19TextString 32023-02-21012023-02-2101
52023-02-19TextString 4
62023-02-19TextString 5
72023-02-19TextString 1
82023-02-19TextString 2
92023-02-19TextString 3
102023-02-19TextString 4
112023-02-19TextString 5
122023-02-20TextString 1
132023-02-20TextString 2
142023-02-20TextString 3
152023-02-20TextString 4
162023-02-20TextString 5
172023-02-20TextString 1
182023-02-21TextString 2
192023-02-21TextString 3
202023-02-21TextString 4
21
Sheet11
Cell Formulas
RangeFormula
E2:F4E2=COUNTIFS($A$2:$A$20,$D2,$B$2:$B$20,E$1)
H2:I4H2=SUM((--(H$1=$B$2:$B$20))*(--($G2=$A$2:$A$20)))
 
Upvote 0
Another option
Fluff.xlsm
ABCDEFG
1DateTextTextString 1TextString 2
219/02/2023TextString 119/02/202322
319/02/2023TextString 220/02/202321
419/02/2023TextString 321/02/202301
519/02/2023TextString 4
619/02/2023TextString 5
719/02/2023TextString 1
819/02/2023TextString 2
919/02/2023TextString 3
1019/02/2023TextString 4
1119/02/2023TextString 5
1220/02/2023TextString 1
1320/02/2023TextString 2
1420/02/2023TextString 3
1520/02/2023TextString 4
1620/02/2023TextString 5
1720/02/2023TextString 1
1821/02/2023TextString 2
1921/02/2023TextString 3
2021/02/2023TextString 4
21
Data
Cell Formulas
RangeFormula
E2:E4E2=UNIQUE(FILTER(A2:A100,A2:A100<>""))
F2:G4F2=COUNTIFS(A:A,E2,B:B,$F$1:$G$1)
Dynamic array formulas.
 
Upvote 0
Fantastic - you taught me a great trick. Thank you.
 
Upvote 0
Fantastic - you taught me a great trick. Thank you.
Not sure if that is for @Fluff or me, but regardless I'm pleased you found a solution.

If you believe one of the posts here has provided you with a solution, please mark it as the answer.
 
Upvote 0
One more solution for your consideration with Power query

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date", "Text"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"

Book4
ABCDEF
1DateTextDateTextCount
22/19/2023TextString 12/19/2023TextString 12
32/19/2023TextString 22/19/2023TextString 22
42/19/2023TextString 32/19/2023TextString 32
52/19/2023TextString 42/19/2023TextString 42
62/19/2023TextString 52/19/2023TextString 52
72/19/2023TextString 12/20/2023TextString 12
82/19/2023TextString 22/20/2023TextString 21
92/19/2023TextString 32/20/2023TextString 31
102/19/2023TextString 42/20/2023TextString 41
112/19/2023TextString 52/20/2023TextString 51
122/20/2023TextString 12/21/2023TextString 21
132/20/2023TextString 22/21/2023TextString 31
142/20/2023TextString 32/21/2023TextString 41
152/20/2023TextString 4
162/20/2023TextString 5
172/20/2023TextString 1
182/21/2023TextString 2
192/21/2023TextString 3
202/21/2023TextString 4
Sheet2
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,929
Messages
6,122,314
Members
449,081
Latest member
tanurai

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