Skip to content

docs: Add example for aggregating percentage changes in DataTable#3272

Open
RamiNoodle733 wants to merge 1 commit intoevidence-dev:mainfrom
RamiNoodle733:docs-datatable-percentage-example
Open

docs: Add example for aggregating percentage changes in DataTable#3272
RamiNoodle733 wants to merge 1 commit intoevidence-dev:mainfrom
RamiNoodle733:docs-datatable-percentage-example

Conversation

@RamiNoodle733
Copy link

Description

Fixes #2592

This PR adds a new documentation section showing how to properly aggregate percentage changes (like year-over-year growth rates) in DataTable total rows.

Problem

When aggregating percentage changes (e.g., growth rates), a simple mean doesn't give the correct overall growth rate because it doesn't account for the different base sizes of each row.

Solution

Use totalAgg=weightedMean with the base metric (e.g., sales, GDP) as the weightCol. This ensures the total growth rate is properly weighted by the size of each row.

Changes

  • Added new "Aggregating Percentage Changes" section under Total Row examples
  • Included example query and DataTable code showing proper weighted mean usage

Checklist

  • For changes to the documentation website, the changes have been previewed locally
  • If there are any new components, add them to the exports in src/lib/index.ts
  • If there are any changes to the query store, make sure the query store types are properly reflected in TypeScript
  • If there are changes to the CLI, document them in the CLI docs
  • If there are changes to the VSCode extension, update the CHANGELOG

Adds a new section showing how to properly aggregate percentage changes
(like YoY growth rates) using weightedMean with the base metric as the
weight column. This ensures the total growth rate is correctly weighted
by the size of each row.

Fixes evidence-dev#2592
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs]: Show example of how to aggregate percentage changes in DataTable

1 participant