Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sites/docs/pages/components/data/data-table/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ limit 5
```
</DocTab>

:::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
Expand Down
8 changes: 4 additions & 4 deletions sites/example-project/src/pages/tables/total-rows/+page.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ If no `weightCol` is specified, the result will be identical to the result from
<Column id=prev_sales_usd0k totalAgg=weightedMean weightCol=sales_usd0k/>
<Column id=prev_num_orders_num0 totalAgg=weightedMean weightCol=sales_usd0k/>
<Column id=prev_aov_usd2 totalAgg=weightedMean weightCol=sales_usd0k/>
<Column id=sales_change_pct0 totalAgg=weightedMean weightCol=sales_usd0k/>
<Column id=num_orders_change_pct0 totalAgg=weightedMean weightCol=sales_usd0k/>
<Column id=aov_change_pct0 totalAgg=weightedMean weightCol=sales_usd0k/>
<Column id=sales_change_pct0 totalAgg=weightedMean weightCol=prev_sales_usd0k/>
<Column id=num_orders_change_pct0 totalAgg=weightedMean weightCol=prev_num_orders_num0/>
<Column id=aov_change_pct0 totalAgg=weightedMean weightCol=prev_aov_usd2/>
</DataTable>


Expand Down Expand Up @@ -317,4 +317,4 @@ SELECT 'Brazil', 'South America', 1609, 0.032, 0.1375, 0.1007, 0.091, -4.5, 80.2
<Column id=debt_to_gdp totalAgg=mean fmt='0"%"'/>
<Column id=current_account totalAgg=mean fmt='0.0"%"'/>
<Column id=population totalAgg=sum fmt='#,##0"M"'/>
</DataTable>
</DataTable>
Loading