Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an csv data dump which is a flattening of related tables from a sql database. So to simplify it looks like this.

| col1 | col2 | col3 | col4 |
+------+------+------+------+
|  A   |  Ad  |  B   |  B1  |
|  A   |  Ad  |  B   |  B2  |
|  A   |  Ad  |  B   |  B3  |
|  A   |  Ad  |  C   |  C1  |
|  A   |  Ad  |  C   |  C2  |
|  X   |  Xx  |  D   |  D1  |
|  X   |  Xx  |  D   |  D2  |
|  X   |  Xx  |  E   |  E3  |

From this table I need to generate various graphs and pivots from subsets of this data

so I would like to generate (link) to this data and create tables that represent the queryable sets I am after eg.

| col1 | col2 |
+------+------+
|  A   |  Ad  |  
|  X   |  Xx  |

and

| col1 | col2 | col3 | 
+------+------+------+
|  A   |  Ad  |  B   | 
|  A   |  Ad  |  C   | 
|  X   |  Xx  |  D   | 
|  X   |  Xx  |  E   | 

mostly so I can do counts of the unique combinations of the flattened data.

It is important that when I refresh the data from the datasource that these tables update accurately.

So how do I do this?

EDIT

Your answers have been helpful, it seems my question wasn't quite good enough

for the first table I really want to produce this

| col1 | col2 | count
+------+------+------
|  A   |  Ad  |  1
|  X   |  Xx  |  1

and the second one

| col1 | col2 | col3 | count
+------+------+------+------
|  A   |  Ad  |  B   |  1
|  A   |  Ad  |  C   |  1
|  X   |  Xx  |  D   |  1
|  X   |  Xx  |  E   |  1

So the counts reflect the distinct record count at a given level not the sum of all rows.

I need to answer questions like "what is the total of distinct items in col1"

I also need to answer this question "show count of col3 for col1"

I expect I will be asked to make graphs and present the data at various normalized levels too.

I hope this is more accurate for you. Thanks for the help so far

share|improve this question
1  
You can use pivot table. For first result table, set col1 and col2 as row labels, set report layout to tabular form, turn off subtotals and grand total. For count of unique combinations, set values to count of column 2. Similar process for second result table, just add col3. –  chuff May 23 '13 at 22:53

2 Answers 2

up vote 2 down vote accepted

On the basis that one picture is worth a thousand words:

SU599258 example

  1. Select A:D, Insert > Tables - PivotTable, PivotTable and accept defaults (though restrict range if you do not want (blank) to appear in the results and you can't be bothered to filter it out - but then remember to increase the range if an update entails more rows. Also you could opt to include the PivotTable in the same sheet, as I have for ease of illustration.)
  2. Drag the fields to the locations shown in the PivotTable Field List example (which is for the right hand PivotTable) and ensure that values is set to Count of. (If not, left click on it and then on Value Field Settings..., select Count and OK).
  3. For the format shown I chose, having left clicked on the PivotTable, Design > Layout - Report Layout, Show in Tabular Form.
  4. If you see subtotals you don't want, right click on an instance of each of the fields involved, choose Field Settings and select None, OK.
  5. Create the second PivotTable from the first.

Note The PivotTables will not change until refreshed, though that is a simple matter of right clicking on either and selecting refresh.

Call back if you require clarification.


Edit in response to clarification of requirement

Rather than forego some analysis that might be useful even if not required at present, simply add a calculated field to each 'existing' PivotTable, eg =COUNT('col3').

updated SU599258 example

share|improve this answer

Excel has PivotTables and PivotCharts. For Excel 2007 or later, select the range containing your source data, go to the Insert tab, and choose which one you want to create. Microsoft has an overview on their website.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.