diff --git a/sites/docs/pages/components/data/data-table/index.md b/sites/docs/pages/components/data/data-table/index.md index dc1f579fdc..89d7d4e31f 100644 --- a/sites/docs/pages/components/data/data-table/index.md +++ b/sites/docs/pages/components/data/data-table/index.md @@ -368,6 +368,11 @@ limit 5 ``` +:::tip Weighted Mean for Percentage Changes +When aggregating percentage changes (e.g., year-over-year growth rates), use `weightCol` to specify the **baseline/previous value** column, not the current value. This ensures the weighted average is calculated correctly, as percentage changes are relative to their original values. + +For example, if you have `sales_change_pct` calculated as `(current_sales - previous_sales) / previous_sales`, the `weightCol` should be `previous_sales`. +::: #### Custom Aggregations Values diff --git a/sites/example-project/src/pages/tables/total-rows/+page.md b/sites/example-project/src/pages/tables/total-rows/+page.md index e4bf7f4c9b..0ad2f4f4bc 100644 --- a/sites/example-project/src/pages/tables/total-rows/+page.md +++ b/sites/example-project/src/pages/tables/total-rows/+page.md @@ -206,9 +206,9 @@ If no `weightCol` is specified, the result will be identical to the result from - - - + + + @@ -317,4 +317,4 @@ SELECT 'Brazil', 'South America', 1609, 0.032, 0.1375, 0.1007, 0.091, -4.5, 80.2 - \ No newline at end of file +