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
1
vote
0 answers

How to plot multiple bar graphs in the same excel using python pivot tables

For this sample code : df_pivot_comp = pd.pivot_table(pd.read_excel(excel_file,sheet_name=sheet),\ values=['COMPILER WARNING'], columns=None, index=['GROUP','DOMAIN'],\ …
1
vote
0 answers

Making a Pivot Table with pywin32, seeing errors with win32com.client.constants

I do a lot of excel work and am looking to migrate from VBA to python. I'm trying to create a pivot table and add the necessary pivot fields. I followed example code from this site but am stuck trying to get the win32com.client.constants to work…
Connor38
  • 11
  • 1
1
vote
0 answers

Creating a variable row table from pivot table

struggling Excel user here. I think the below is likely relatively simple athough I am struggling to phrase the question, and therefore can't find answers online. I have a list of names from a Pivot table, I am wanting to transfer these names to a…
Lee
  • 23
  • 3
1
vote
1 answer

How to divide one pandas dataframe (pivot table) by another if columns names are different?

What I am trying to do I am calculating certain pivot tables with pandas , and I want to divide one by the other. An example (with fictional data) is below, where I have data on the sales of certain items, and I want to calculate things like total…
Pythonista anonymous
  • 8,140
  • 20
  • 70
  • 112
1
vote
2 answers

How to GROUP BY Multiple Columns and COUNT in Excel

I want to group 3 columns (Fruit, Color & Vendor) and get their corresponding group count in excel, without using any VBA code, but just simply using Excel functions. Fruit Vendor Ledger Table: ID Fruit Color Vendor 1 Apple Red Rocket…
GaryTheBrave
  • 97
  • 11
1
vote
1 answer

Get Pivot table names as per their physical order in the sheet

Main Excel Sheet As you can see in the image, there are some pivot tables on the Excel sheet. Although they are named PivotTable1 to PivotTable11, they aren't present in the same physical order in the sheet. I want to get the names of the pivot…
1
vote
0 answers

How to update Pivot table source range in Google App Script dynamically

I have a Form Builder Sheet where I have added Questions, and their Options using App Script. Added a Triger that updated every day. I have set this form Builder sheet, due to change of questions every day or can be changed as per need like…
AL SADAT
  • 11
  • 1
1
vote
1 answer

how to use both #gtsummary and #tidyverse for cross-tabulation showing chi-square and t-test results in R

I want to cross tabulate member and author in the rows and review, publish and pay in the column showing row and column total with percentages in bracket and chi-square test in the footnote. #data set.seed(123) member <- sample(c("Yes", "No"), 100,…
Cherson
  • 13
  • 3
1
vote
2 answers

How to combine multiple crosstabs while preserving same binary column

I would like stack 2 crosstabs for 2 categorical variables (gender, race) while preserving the same binary variable (goal) as columns. Take for example this dataset: df = pd.DataFrame({'GenderDSC':['Male','Female','Female','Male','Male','Male'], …
Gabe Verzino
  • 346
  • 1
  • 10
1
vote
2 answers

Group/Pivot Data Values By First & Last Entry in DataFrame

Let's assume I have the following data (in reality I have millions of entries): import pandas as pd import numpy as np import datetime as dt df_data = pd.DataFrame([ [dt.date(2023, 5, 8), 'Firm A', 'AS', 250.0, -1069.1], [dt.date(2023, 5,…
Phil-ZXX
  • 2,359
  • 2
  • 28
  • 40
1
vote
1 answer

Pivot Table Count Macro

I´m trying to do a Macro that includes a Pivot Table, but I´m unable to make it work... When I record the macro all works OK, but when I execute it again, it does not deliver the expected results... This is an Example of Original Data This is what…
Fokker80
  • 13
  • 3
1
vote
1 answer

Excel: pivot ungroup date and compare data by days

I have pretty much understood how group and ungroup data works in excel but one thing is not very clear: I have a table like…
1
vote
1 answer

Pivot Tables, vba and .cubefields

I have a pivot table that is part of a data model (to ensure when filtering, calculations don't change). The following code was tested on a replica of the pivot table that is not part of a data model and it works 100% as I expect it to. Sub…
Keiran
  • 31
  • 6
1
vote
1 answer

Specifying Which Column a Max Value Came From in an Excel Table

My example table Part Number 00 01 02 03 04 EX Max…
1
vote
1 answer

Google Sheets : How can I sum two calculated fields in a pivot table

Inside a pivot table, I want to store in the Baz column the sum of Foo and Bar column. How can I reference the B and C columns so Baz = Foo + Bar ? I tried to : Reference the columns by theirs names : Does not work Reference the columns by theirs…
Jean
  • 1,707
  • 3
  • 24
  • 43