superset icon indicating copy to clipboard operation
superset copied to clipboard

Sort by is not working for Pivot Table and Pivot Table V2 chart

Open bonamim opened this issue 2 years ago • 18 comments

Sort by is not working for Pivot Table and Pivot Table V2 chart.

How to reproduce the bug

  1. Create a [Pivot Table] or [Pivot Table V2] chart;
  2. Add some fields in Row section and one metric in the Metrics section;
  3. Try to sort the data using the metric.

Expected results

When SORT DESCENDING is selected, the data in the pivot table should be in descending. It is possible to see in the images below that the sorting is respected in the Results section, but in the pivot table nothing happens.

Actual results

  • Pivot Table image

  • Pivot Table V2 image

Environment

  • browser type and version: Chrome (Version 110.0.5481.177)
  • superset version: superset version 2.0.1
  • any feature flags active:
    • ENABLE_TEMPLATE_PROCESSING
    • DASHBOARD_RBAC

Checklist

Make sure to follow these steps before submitting your issue - thank you!

  • [ ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [x] I have reproduced the issue with at least the latest released version of superset.
  • [x] I have checked the issue tracker for the same issue and I haven't found one similar.

Additional context

  • Helm Chart;

bonamim avatar Mar 13 '23 18:03 bonamim

Same problem here :(

Sansinj avatar May 24 '23 18:05 Sansinj

Same problem

HeathLee avatar Jun 16 '23 13:06 HeathLee

Same problem

smiren avatar Jun 20 '23 11:06 smiren

The same problem here

smiren avatar Jun 20 '23 11:06 smiren

Same problem seen by me

gajendersingh1982 avatar Jul 07 '23 10:07 gajendersingh1982

same here :( , please fix because it makes the table not usable for the user to quickly look at a lot of data

seantdinh avatar Jul 29 '23 01:07 seantdinh

Can anyone validate whether or not this is still an issue in 3.x or newer versions? We no longer support 2.x, so I'm tempted to close this as stale, but if we can get a working failure case for 3.x using example/sample data, that'd be great.

rusackas avatar Mar 06 '24 21:03 rusackas

@rusackas The issue remains the same: sorting in pivot tables doesn't work, as it displays data in a random order.

ProdigyMaster avatar Mar 18 '24 07:03 ProdigyMaster

I'm seeing the same issue in Preset version 2024.8.2. The query that runs is correct, but the pivot table sorts in ascending order for this example:

SELECT DATE_TRUNC('month', order_date) AS order_date,
       state AS state,
       COUNT(*) AS count
FROM public."Vehicle Sales"
GROUP BY DATE_TRUNC('month', order_date),
         state
ORDER BY 1 DESC
LIMIT 10000

cmcnicoll avatar Mar 20 '24 20:03 cmcnicoll

same issue, can we pls have a patch for this in the next updated version

lindsay-kk avatar Mar 27 '24 03:03 lindsay-kk

We have the same issue

liany-dropit avatar Apr 01 '24 11:04 liany-dropit

We too have encountered the exact same issue!

image

swami-kf avatar Apr 06 '24 06:04 swami-kf

Same here!

jamzl avatar Apr 19 '24 08:04 jamzl

Same here!

eliaetzensperger avatar Jun 04 '24 08:06 eliaetzensperger

Same here! Any known workaround?

rtotheb2000 avatar Jun 27 '24 12:06 rtotheb2000

Same here! Still in 4.0.2

zlzdmv2022 avatar Aug 14 '24 03:08 zlzdmv2022

same problem here: Version: 4.0.2

ngocdd avatar Aug 26 '24 03:08 ngocdd

Have tried 4.0.1 and 4.0.2 still no ability to sort except alphabetic or numeric sorts of the first column. It's quite ridiculous that a chart as basic as a pivot table cannot have a column sort that works.

kpiforgeoliver avatar Oct 16 '24 00:10 kpiforgeoliver

Same here in version 4.1.1

kenho811 avatar Dec 14 '24 04:12 kenho811

This is still broken in 4.1.1. Please Please Please create a way for us to sort values in a pivot table by a column of our choosing. This is basic usage of a pivot table to be able to sort by different columns. Many people have a specific order they need to see the data, and only being able to sort alphabetically or numerically by the first column in a pivot table is a non-starter.

kpiforgeoliver avatar Dec 20 '24 15:12 kpiforgeoliver

Same problem here, is there a workaround or something fo fix it at least in local?

MarcoFranchin96 avatar Feb 10 '25 17:02 MarcoFranchin96

I'm using Superset 4.1.1 and cannot sort by another column or metric. Do you have any update on this problem? @rusackas

bluespring2812 avatar Feb 14 '25 06:02 bluespring2812

What if it were implemented that row and column headers in a Pivot Table V2 could be sorted freely? This seems useful in several cases, e.g., for weekdays or months, but also for school types, etc. Anything that has an inherent order and cannot be sorted alphabetically. That seems to be a regularly requested feature:

  • https://stackoverflow.com/questions/76118640/how-can-i-sort-my-month-in-the-correct-order-in-a-pivot-table?rq=2
  • https://stackoverflow.com/questions/75797423/how-to-sort-days-of-the-week-in-a-pivot-table-in-superset
  • https://github.com/apache/superset/discussions/18469
  • https://github.com/apache/superset/issues/6137

rtotheb2000 avatar Mar 09 '25 07:03 rtotheb2000

That'd be awesome @rtotheb2000

ulevitsky avatar Apr 01 '25 01:04 ulevitsky