Questions tagged [pivot-table]

A "pivot table" is a method of summarizing data in tabular form. Typically, these have a category column in the left hand side, and multiple summary columns to the right. Each different category will have its own row. Be sure to include the relevant language tag (python, excel, R, postgreSQL etc.) on your question.

A "pivot table" is a method of summarizing data in tabular form. Typically, these have a category column in the left hand side, and multiple summary columns to the right. Each different category will have its own row.

Pivot tables are typically found in data visualization programs, including spreadsheets and business intelligence. Note that a "pivot table" is also known as a "cross tab" or "cross tabulation".

Resources:

8105 questions
2
votes
1 answer

Can we have multi-dimensional values in pivot-table pandas?

I am using the pandas library for creating pivot tables in csv files. The usual format of the pivot_table code is something like the bottom code. tips=read_csv('tips.csv') `table=pd.pivot_table(tips, values='tip_pct', rows=['time', 'sex'],…
jxn
  • 7,685
  • 28
  • 90
  • 172
2
votes
0 answers

Excel pivot-table unable to sort columns using VBA code

I'm using Excel 2010 and currently writing some VBA code to control my pivot-table. My issue is that I'm using Shapes to access a vba macro responsible to sort my table and it only works when I sort the first column of my pivot table. Here's the…
ElCapitaine
  • 830
  • 1
  • 11
  • 24
2
votes
1 answer

Getting percentage of another Column in Pandas Pivot Table

I am trying to get similar excel functionality in pandas, mainly a % of type behavior. Using the following data: {'A': ['a', 'b', 'b', 'a', 'a', 'a', 'b', 'b', 'b', 'a', 'a', 'a', 'b'], 'C': ['e', 'e', 'e', 'f', 'f', 'f', 'f', 'f', 'f', 'f', 'f',…
Jon
  • 734
  • 1
  • 7
  • 30
2
votes
3 answers

Why is my pivot table showing different values than the table it's based on?

I have a simple table with names of employees and whether or not they've met a certain criteria ('yes' or 'no' in a column). I've created a pivot table using insert/pivot table. When I insert a slicer for employees and filter down to one name, I…
sonicblis
  • 2,926
  • 7
  • 30
  • 48
2
votes
1 answer

How to write PIVOT query with Joins and Groupby

Hi I have created a MS SQL query it is generating perfect results. But I need to change the values of rows and columns. I have searched over internet and learned about PIVOT to change the orientation. I have created some small queries but I am not…
MaxPayne
  • 1,028
  • 1
  • 12
  • 19
2
votes
1 answer

Transposing column into rows and create new column?

I have the following table Col_1 Col_2 Col_3 Date 0.1 0.2 0.3 2013-08-13 0.4 0.5 0.6 2013-08-12 I want the following: Date New Column Value 2013-08-13 Col_1 0.1 2013-08-13 Col_2 …
Prakhar Mehrotra
  • 1,215
  • 4
  • 16
  • 21
2
votes
1 answer

Web pivot table componet showing text in pivot table data area

I have found these great pivot table components on the web nicolaskruchten - pivottable ZKOSS - pivottable RJackson - pivottable My problem (or question) lies in the fact that pivot tables inherently "pivot" data around a numeric data-set; meaning…
Hightower
  • 968
  • 4
  • 24
  • 58
2
votes
1 answer

How to restore\unfold multiindex in pandas DataFrame

I am very close to go insane. I have a dataframe like this: subject sessionIndex screenIndex index key time s019 1 3 1 Shift 0.3442 s019 1 3 2 Shift.t 0.1514 s019 …
2
votes
0 answers

How do I do Excel-style "Calculated fields" (including subtotals) in a pandas pivot_table?

So, say I have an army of Salvation-Army-style bell-ringing Santas who are collecting money on the streets in the days leading up to Xmas. My data looks like: Day AM/PM Santa Donors Revenue 12/22/2012 AM Candi 92 $762.56…
Jonathan Harford
  • 361
  • 1
  • 3
  • 9
2
votes
2 answers

Excel VBA: clear items in pivot table

I am new to VBA... I am trying to write a macro that will clear all the selections within a pivot table filter named "Product Family" and select only the item whose name is contained in cell "B33". I am referencing the pivot table in one sheet…
Ben
  • 107
  • 1
  • 2
  • 8
2
votes
4 answers

Changing pivot table filter based on a drop down

I have drop down which has a list of countries. I need the pivot table to be filtered based on the country selected on the drop down. I am using this code. Sub PivotChange(ByVal Target As Range) If Not Application.Intersect(Target,…
SAM244776
  • 1,375
  • 6
  • 18
  • 26
2
votes
5 answers

Convert row with columns of data into column with multiple rows in Excel 2007

I have a row of data as follows: header1 header2 header3 header4 header5 row key datavalue1 datavalue2 datavalue3 datavalue4 datavalue5.... so basically, I have a denormalized data set where the…
jhc
  • 103
  • 3
  • 5
  • 13
2
votes
1 answer

SQL Server 2008: Creating dynamic column names

I have a problem that I cannot solve. I work on Microsoft SQL Server 2008 and I have a table with four columns Id Date (2013-07, 2013-08, 2011-03, etc) Amount 1 (100, 150, etc.) Amount 2 (100, 80, etc.) If Amount 1 > 150 then I need to create new…
user2561907
  • 23
  • 1
  • 1
  • 3
2
votes
2 answers

MySQL dynamic pivot table

Im trying to get a pivot table with dynamic columns to work. When user_id is a string, it works fine but if its an int, then it seems to fail Here is what I have so far with the assistance of past questions: CREATE TABLE measure2 …
Mitchell Weiss
  • 93
  • 1
  • 4
  • 9
2
votes
2 answers

How can I reduce the number of joined tables in this query?

CREATE TABLE Attributes ( id VARCHAR(40), type VARCHAR(16), data VARCHAR(2048), PRIMARY KEY(id,type) ); This is the general format of query I am trying to run. The general idea is that 'objects' have unique ids and then…
chacham15
  • 13,719
  • 26
  • 104
  • 207