-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
Steps to reproduce
Steps:
- Open this link to live example: https://stackblitz.com/edit/zvyat1a6?file=src%2FDemo.tsx
- Sort by transaction date
- See how the aggregated value for "Price (first)" doesn't change
Current behavior
Aggregation doesn't honor sorting, which prevents some aggregations such as "First/Last". This is especially an issue in pivoting and row grouping of data where values don't stack (e.g. share price), but you would want to show e.g. the latest share price for the quarter instead.
We work a lot with financial data, and thus find pivoting borderline useless until we get first/last (or better yet latest) aggregations to work. Summing share prices, multiples, etc. makes little sense, but we do want to show the most recent value per quarter for example.
I have also tried to hack this by overriding getCellValue
and returning the whole row for it + comparing dates. But within pivoting, it returns values for all the rows, and new columns get autogenerated that hold the actual values for that specific column, but it's not possible to understand which dynamic column we're aggregating at a given point. Hence, overriding getCellValue
breaks aggregation completely.
Reproduction: https://stackblitz.com/edit/zvyat1a6-eigrrkht?file=src%2FDemo.tsx
Check console, for every column that we're aggregating, all price values are available, hence Google's first share price becomes completely wrong ($1000, which it not even a valid value).
Expected behavior
- Aggregation values should be provided in a sorted order
- getCellValue should only fetch values for the pivoted column, not all columns
Context
Ag-grid offers this out of the box (click on values -> first(Gold)): https://www.ag-grid.com/javascript-data-grid/pivoting/
Your environment
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Search keywords: aggregation sorting pivot first last latest