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 Apache Superset Sort by is not working for Pivot Table and Pivot Table V2 chart

  • Pivot Table V2 Apache Superset Sort by is not working for Pivot Table and Pivot Table V2 chart

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;

Comment From: Sansinj

Same problem here :(

Comment From: HeathLee

Same problem

Comment From: smiren

Same problem

Comment From: smiren

The same problem here

Comment From: gajendersingh1982

Same problem seen by me

Comment From: seantdinh

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

Comment From: rusackas

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.

Comment From: ProdigyMaster

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

Comment From: cmcnicoll

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

Comment From: lindsay-kk

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

Comment From: liany-dropit

We have the same issue

Comment From: swami-kf

We too have encountered the exact same issue!

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

Comment From: jamzl

Same here!

Comment From: eliaetzensperger

Same here!

Comment From: rtotheb2000

Same here! Any known workaround?

Comment From: zlzdmv2022

Same here! Still in 4.0.2

Comment From: ngocdd

same problem here: Version: 4.0.2

Comment From: kpiforgeoliver

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.

Comment From: kenho811

Same here in version 4.1.1

Comment From: kpiforgeoliver

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.

Comment From: MarcoFranchin96

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

Comment From: bluespring2812

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

Comment From: rtotheb2000

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

Comment From: ulevitsky

That'd be awesome @rtotheb2000

Comment From: rusackas

Related (or duplicate) issue: https://github.com/apache/superset/issues/20564