Count Unique items based on criteria

trenteb

New Member
Joined
Dec 19, 2023
Messages
7
Office Version
  1. 2021
Platform
  1. Windows
I have a set of sales data by date by location and by customer. I want to be able to count the customers who have purchased by month by location, whether they have purchased multiple times during the month or just once doesn't matter they should only be counted once as trying to ascertain the number of active customers.

Note - not able to post mini sheet, not being provided with option?
 

Attachments

  • countsample.png
    countsample.png
    18.9 KB · Views: 9
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type date}}),
    #"Extracted Month Name" = Table.TransformColumns(#"Changed Type", {{"Month", each Date.MonthName(_), type text}}),
    #"Grouped Rows" = Table.Group(#"Extracted Month Name", {"Month", "Sales Office", "Category", "Customer Name"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}}),
    #"Removed Columns" = Table.RemoveColumns(#"Grouped Rows",{"Count"})
in
    #"Removed Columns"

Book7
FGHI
1MonthSales OfficeCategoryCustomer Name
2NovemberROCBlackCustomer A
3NovemberABCGreenCustomer C
4NovemberSHEGreenCustomer E
5NovemberSHEBlackCustomer F
6OctoberROCYellowCustomer A
7OctoberABCBlackCustomer C
8OctoberABCGreenCustomer D
9OctoberSHEYellowCustomer E
10OctoberSHEYellowCustomer F
11OctoberSHEGreenCustomer F
12SeptemberROCBlackCustomer A
13SeptemberROCYellowCustomer A
14SeptemberROCYellowCustomer B
15SeptemberABCYellowCustomer C
16SeptemberABCGreenCustomer C
17SeptemberSHEGreenCustomer E
18SeptemberSHEBlackCustomer E
19AugustROCBlackCustomer B
20AugustABCBlackCustomer C
21AugustABCGreenCustomer D
22AugustSHEGreenCustomer E
23AugustSHEYellowCustomer E
24AugustSHEYellowCustomer F
25JulyABCGreenCustomer C
26JulyABCYellowCustomer D
27JulySHEYellowCustomer G
28JulySHEBlackCustomer F
29JulySHEGreenCustomer F
30JulySHEGreenCustomer E
Sheet2
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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