From cae0959756bfe818b17cd179af307cdc92570487 Mon Sep 17 00:00:00 2001 From: Diego Medina Date: Tue, 8 Mar 2022 13:08:51 -0300 Subject: [PATCH] fix: custom SQL in Sort By Breaks Bar Chart --- superset/viz.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset/viz.py b/superset/viz.py index 11f052813d024..91612e09fd705 100644 --- a/superset/viz.py +++ b/superset/viz.py @@ -1841,7 +1841,7 @@ def get_data(self, df: pd.DataFrame) -> VizData: # pylint: disable=too-many-loc sortby = utils.get_metric_name( self.form_data.get("timeseries_limit_metric") or metrics[0] ) - row = df.groupby(groupby).sum()[sortby].copy() + row = df.groupby(groupby)[sortby].sum().copy() is_asc = not self.form_data.get("order_desc") row.sort_values(ascending=is_asc, inplace=True) pt = df.pivot_table(index=groupby, columns=columns, values=metrics)