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
2 answers

Excel pivot table with running total grand total is incorrect

I have data with list of people and their activities by dates. I need to distinct count how many exact activities by one person in one day was made. My data: Date Person Activity Exact Activity 2023/04/04 Alex Walking Walking with the…
Katia
  • 53
  • 13
1
vote
1 answer

SQL SERVER - Create Table by matching rows and columns and put Y or N

I currently have a table with all the data, using this data i want to create another table which could be used for auditing purpose (similar layout like pivot table) Example Below: Raw Data Name Places…
K-M
  • 660
  • 3
  • 13
  • 27
1
vote
3 answers

Databricks PySpark Explode and Pivot Columns

I've been working on some data, trying to clean some data and I've found some difficulties that I hope this community can help me with. I have this json structure { "date": "04/23/2023" ,"eventName": "click" ,"UserProperties": [{ "key": "Name" …
KarenFri
  • 21
  • 3
1
vote
1 answer

Is it possible to do a pivot table with concatenated aggregations with tbl_summary in R

Problem I have a data.frame including 18 parameters measured at 6 timepoints. I would like to display the mean+standard deviation of each parameter according to each timepoint in a pivot table. Expected output An example table, which includes only…
barerd
  • 835
  • 3
  • 11
  • 31
1
vote
1 answer

how to pivot table from excel to pandas

My csv contain like (df) : item_group item_code total_qty total_amount cost_center 0 Drink IC06-1P 1 3.902 Cafe II 1 Drink IC09-1 1 2.927 Cafe II 2 BreakFast FS04-2 …
tree em
  • 20,379
  • 30
  • 92
  • 130
1
vote
0 answers

How to fix column order after pivot_table

I have the following DataFrame where the bit column is in ascending order: calc1 = pd.DataFrame({ 'byte': ['D0']*2 + ['D1']*2, 'bit' : [f'bit_{i}' for i in range(7, 11)], 'count': ['a', 'b', 'c', 'd'] }) byte bit count 0 D0 …
fabio-dc
  • 11
  • 4
1
vote
2 answers

Create conditional multi-index subtotal on pivoted dataframe

I have a multi-index pivot table looks like the following, where Date is the index, and columns are [country, attributes]: net_supply = pivot_filter.pivot_table(values='Production', index='Date',…
1
vote
1 answer

pandas pivot_table to include every index

I would like to get a dataframe of counts from a pandas pivot table, but for the aggregate function to include every index. For example df1 = pd.DataFrame({"A": ["foo", "bar", "shtuff"], "B": ["one", "two", "one"], …
Juliepvr
  • 33
  • 3
1
vote
2 answers

SPSS: trying to summarise the ranking of items, from a survey with drag&drop question

I get the following data from a survey, with just a drag&drop question to rank favorite brands, between BMW, Mercedes, and Audi: BMW Mercedes Audi 1 3 2 2 1 3 2 3 1 1 2 3 3 1 2 With SPSS, I need to output a table of counts for…
Thierry G.
  • 193
  • 1
  • 8
1
vote
1 answer

Dynamic pivot table in MariaDB not working query in php

Hey guys can you help me i need to convert this query in to an PHP code. set @sql = ( select group_concat(distinct concat( "sum(case when `test_id`='",test_id, "' then `points` ELSE '0' end) as `", `test_id`, "`" ) …
1
vote
1 answer

Displaying filters horizontally

I have created a macro to create a pivot table. I have recorded the macro and when I recorded it, all the filters on pivot macro stacked (image 1). However when I run the macro it is putting all the filters horizontally instead of stacking them on…
PhaseOn
  • 37
  • 5
1
vote
1 answer

Filter only certain columns in Excel Pivot Tables

I have a table that contains a list of dates for planned and dispatched orders, the table looks like this - What I am trying to do is generate a pivot table from this. The issue I'm having is that I only want it to be filtered by each individual…
Drawleeh
  • 297
  • 1
  • 10
1
vote
1 answer

SQL - Create a pivot-table like table filling columns with values from other columns

I have a table like in SQL like: Id flag_0 doc date 1 1 1 d1 1 1 2 d2 1 1 3 d3 2 0 1 d4 2 0 2 d5 I want a query to reach the following table: Id flag_0 doc_1 doc_2 doc_3 1 1 d1 d2 d3 2 0 d4…
1
vote
0 answers

Calculated field with if statements for years in excel

I'm trying to create a calculated fiel on excel in a pivot table to get some values depending on a year field. This is what i want to do: If "Gestion" is 2023 then give me a particular field, if it's less than 2023 give me another. This is my…
lilqasr
  • 15
  • 5
1
vote
0 answers

Excel Pivot Tables: aggregate data by the count of months as columns

I'm looking to build a pivot table which should tell me how many distinct stores have sold an item for a cumulative amount of months. I have sales data from a convenience stores chain. The data is provided by 'item - store - month' level of…
wujie
  • 21
  • 2
1 2 3
99
100