Extract a unique distinct list by matching items that meet a criterion in excel 2007 using pivot table
Anura asks:
I have a list of credit card transactions showing the name of the card holder, their Branch and the amount. I want to produce a report for each Branch, so what I want is to extract only those people who match the Branch name. For example:
Frank Branch A
Frank Branch A
Frank Branch A
Joe Branch A
Mary Branch B
Jane Branch C
Mike Branch A
Joe Branch A
Dave Branch C
I would like a list of only those people for Branch A, and then be able to summarise the transactions. Or should I do this in two stages?
How can I count the number of transactions per person?
Answer:
First create a named dynamic range. If you add new values to your list the named range expands. This makes it easy to update your pivot table with newly added values. Then create a pivot table.
How to create a dynamic named range
This dynamic range formula adds both new columns and rows.
- Click "Formula" tab on the ribbon
- Click "Name Manager"
- Click "New"
- Type a name for the range, I named it "table"
- Type this formula into "Refers to:" field:=OFFSET(Table!$A$1, 0, 0, COUNTA(Table!$A:$A), COUNTA(Table!$1:$1))

- Click OK
The above table has the cell range $A$1:$C$11.
The dynamic range formula =OFFSET(Table!$A$1, 0, 0, COUNTA(Table!$A:$A), COUNTA(Table!$1:$1)) returns the same cell reference $A$1:$C$11.
How to create a pivot table in excel 2007
- Select cell range A1:C11
- Click "Insert" tab on the ribbon
- Click "Pivot table" button
- Type "table" in "Table/Range:" field
- Select where you want the pivot table to be placed
- Click OK
I placed the pivot table on a new sheet.
- Drag and drop "Name" to "Drop Row Fields Here"
- Drag and drop "Branch" to "Drop Column Fields Here"
- Drag and drop "Amount" to "Drop Column Fields Here"
How to create a list of unique distinct values for branch A
How to count the number of transactions per person
Drag and drop "Name" into "Values". See picture below.
How to update pivot table with new values
- Add more values to table
- Right click Pivot table
- Click "Refresh"
Download excel sample file for this tutorial.
unique-distinct-list-matching-criteria-pivot table.xls
(Excel 97-2003 Workbook *.xls)
Functions in this article:
OFFSET(reference,rows,cols, [height],[width])
Returns a reference to a range that is a given number of rows and columns from a given reference
COUNTA(value1,[value2],)
Counts the number of cells in a range that are not empty
Related posts:
Extract a unique distinct list by matching items that meet a criterion in excel
Excel 2007 pivot table: Count unique distinct records (rows)
Change pivot table data source using a drop down list
List people with the highest scores based on criteria in a pivot table (Excel 2007)
























