Bug description
When aggregating pivot tables "First" and "Last" aggregate types act as "Min" and "Max", not taking order of dataset into account. Even though there is a "SORT BY" field in UI, that sorting is not used.
On screenshots the dataset is sorted using "MIN(Genre)", and option is "Last". So i would expect to get % asociated with "Sports" genre (5.54%). What i get is 5.88%, which is simply a MAX of the dataset.
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- [x] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [x] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [x] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hello @ksnikiforov! I'm Dosu, here to assist you with bugs, questions, and contributing tips while you wait for a human maintainer. Let's get this sorted out together!
The issue you're experiencing with the "First" and "Last" aggregate functions in pivot tables is due to their implementation, which does not consider the order of the dataset. These functions are designed to act like "Min" and "Max" by selecting the first and last elements of the series based on the current order, without taking into account any sorting applied in the UI. The "SORT BY" field in the UI does not affect this behavior unless the dataset is explicitly sorted before applying these functions [1].
To continue talking to Dosu, mention @dosu.
Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other
Comment From: rusackas
Thanks for opening the PR!
Comment From: rusackas
Looks like the PR is still green... we'll get it reviewed and close this out. Thanks!