GitHub user BNyamkhuu created a discussion: How to sort time series column 
correctly in Time-Series table ?

Dear developers,

In the "Time-Series Table" chart, clicking a column header to sort the data 
fails to sort numerically if the column has a D3 Number Format applied or is 
configured to display a Sparkline (in the "Time series columns" setup).

There appear to be two underlying causes compounding this issue:

D3 Formatting converts to String: When applying formats that append suffixes 
(e.g., k, M) or fixed decimals (e.g., ,.2f), the frontend table sorts the 
values lexicographically (alphabetically) rather than numerically. For example, 
84k is sorted higher than 2.9M and 150k.

Sparkline Object Wrapper: When a metric is configured as a "Time series column" 
to display a sparkline, the underlying cell value seems to be passed as a 
complex object/array to render the chart. When a user clicks the column header, 
the native frontend sorting logic fails to parse the raw numeric value from 
this object, resulting in broken or random sorting.

Expected behavior:
Clicking a column header should always sort the rows numerically based on the 
raw, unformatted backend value of the metric, regardless of the D3 visual 
formatting applied or whether a Sparkline is rendered in the cell.

Current Workarounds (Sub-optimal):

Casting the metric to ::FLOAT in the Virtual Dataset SQL does not solve the 
frontend sorting issue. Therefore, I delete number format in the chart settings 
doesn't solve the sorting issue.


Environment:

Superset version: 0.0.0.dev0 - superset_superset docker image pull 4 months 
ago. When we running docker container, it's so confusing. 

Database: PostgreSQL

GitHub link: https://github.com/apache/superset/discussions/38937

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to