massucattoj commented on code in PR #41028:
URL: https://github.com/apache/superset/pull/41028#discussion_r3607009092


##########
superset/charts/client_processing.py:
##########
@@ -278,6 +291,38 @@ def pivot_table_v2(
         show_columns_total=bool(form_data.get("colTotals")),
         apply_metrics_on_rows=form_data.get("metricsLayout") == "ROWS",
     )
+    if apply_number_format:
+        return apply_pivot_number_formats(pivoted, form_data)
+    return pivoted
+
+
+def apply_pivot_number_formats(
+    df: pd.DataFrame, form_data: dict[str, Any]
+) -> pd.DataFrame:
+    """
+    Apply `valueFormat`/`columnFormats` and currency config to pivot values.
+
+    The metric name is the first column level, or the last when `combineMetric`
+    moves it there; per-metric overrides fall back to the global value format. 
In
+    the ROWS metrics layout the metric is on the index, so every value column
+    uses the global format.
+    """
+    value_format = form_data.get("valueFormat")
+    column_formats = form_data.get("columnFormats") or {}
+    currency_format = form_data.get("currencyFormat") or {}
+    currency_formats = form_data.get("currencyFormats") or {}
+    metric_level = -1 if form_data.get("combineMetric") else 0

Review Comment:
   Yeaaah u're right . Fixed by resolving the metric from the index (transpose 
→ format → transpose back), with tests for both the plain and combineMetric 
cases. Now matches the frontend behavior.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to