Unique record count with multiple criteria

praveenj

New Member
Joined
Aug 14, 2018
Messages
3
Hi

This is me first time posting on this forum, so hoping someone can answer.

I have data in the below sample format. I am trying to get a record count when the values in column 1(Week) and column2 (Name) match together. For example, User1 has three entries for 7/14/2018. So in column3, I would expect to see 3 in the first row. However, I am getting 1 using the below formula. What do I need to do to fix it?

=SUM(--(FREQUENCY(IF($B$2:$B$10=[@Name], IF($A$2:$A$10=[@Week], MATCH($A$2:$A$10, $A$2:$A$10, 0))), ROW($A$2:$A$10)-ROW(A2)+1)>0))

Week Name Count
7/14/2018 User1 1
7/28/2018 User1 1
6/30/2018 User1 1
7/21/2018 User2 1
7/7/2018 User2 1
7/14/2018 User1 1
7/14/2018 User1 1
7/14/2018 User2 1
7/7/2018 User1 1

Thanks.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Is this what you want?
Excel Workbook
ABC
1WeekNameCount
27/14/2018User13
37/28/2018User11
46/30/2018User11
57/21/2018User21
67/7/2018User21
77/14/2018User13
87/14/2018User13
97/14/2018User21
107/7/2018User11
Sheet
 
Upvote 0
or
Code:
#"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"Week", "Name"}, {{"Count", each Table.RowCount(_), type number}})
 
Upvote 0
Thank you all for the suggestions. They work. What if I want to get a unique count of the weeks associated with User1? In the above example, it should be 4 (6/30, 7/7, 7/14, 7/28)? Thanks.
 
Upvote 0
Thank you all for the suggestions. They work. What if I want to get a unique count of the weeks associated with User1? In the above example, it should be 4 (6/30, 7/7, 7/14, 7/28)? Thanks.

Control+shift+enter, not just enter:

=SUM(IF(FREQUENCY(IF($B$2:$B$10="User1",$A$2:$A$10),$A$2:$A$10),1))
 
Upvote 0
This is an array formula that must be entered with CTRL-SHIFT-ENTER.
Excel Workbook
ABCDEF
1WeekNameCountWeek Count forUser1
27/14/2018User134
37/28/2018User11
46/30/2018User11
57/21/2018User21
67/7/2018User21
77/14/2018User13
87/14/2018User13
97/14/2018User21
107/7/2018User11
Sheet
 
Upvote 0
WeekNameWeekNameCountNameCount
7/14/2018User1
14/07/2018​
User1
3​
User1
4​
7/28/2018User1
28/07/2018​
User1
1​
6/30/2018User1
30/06/2018​
User1
1​
7/21/2018User2
21/07/2018​
User2
1​
07/07/2018​
User2
07/07/2018​
User2
1​
7/14/2018User1
14/07/2018​
User2
1​
7/14/2018User1
07/07/2018​
User1
1​
7/14/2018User2
07/07/2018​
User1

M code for the 2nd result
Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type with Locale" = Table.TransformColumnTypes(Source, {{"Week", type date}}, "en-US"),
    #"Grouped Rows" = Table.Group(#"Changed Type with Locale", {"Week", "Name"}, {{"Count", each Table.RowCount(_), type number}}),
    #"Grouped Rows1" = Table.Group(#"Grouped Rows", {"Name"}, {{"Count", each Table.RowCount(_), type number}}),
    #"Filtered Rows" = Table.SelectRows(#"Grouped Rows1", each ([Name] = "User1"))
in
    #"Filtered Rows"[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,215,909
Messages
6,127,670
Members
449,397
Latest member
Bastbog

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