Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Grain "Week starting Monday" doesn't select data correctly #31927

Open
3 tasks done
AdrianMastronardi opened this issue Jan 19, 2025 · 1 comment
Open
3 tasks done

Comments

@AdrianMastronardi
Copy link

Bug description

Hi,
While migrating a weekly dashboard from Excel to Superset, I found that time grain "Week starting Monday" doesn't select the proper data set.

As far as I understand, when selecting "Week starting Monday" should consider a week from Monday to Sunday, and using Monday as the label for that data aggregation. While time grain "Week ending Sunday" should consider the same time frame but will label the data aggregation uising the Sunday date. Despite the label, both should take the same days for each week.

When I select "Week ending Sunday" I obtain the correct sum for the week, however, when using "Week starting Monday" it takes data from Tuesday to Monday rather than from Monday to Sunday.

I'm attaching the dataset I'm using and two screenshots for the two charts.

I'm using superset 4.1.1

Warm regards.

Screenshots/recordings

Image

Image

Image

Superset version

master / latest-dev

Python version

3.11

Node version

16

Browser

Chrome

Additional context

No response

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • 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.
Copy link

dosubot bot commented Jan 19, 2025

Hey @AdrianMastronardi! I'm here to help you with any bugs, questions, or contribution guidance you may need. Let's squash those bugs together! 🐞

The issue you're experiencing with the "Week starting Monday" time grain in Superset 4.1.1 is due to the way the time grain expression is defined in the code. The expression for TimeGrain.WEEK_STARTING_MONDAY calculates the start of the week by finding the previous Monday and then subtracting 7 days, which effectively shifts the start of the week to Tuesday of the previous week. This results in a week that runs from Tuesday to Monday, rather than the expected Monday to Sunday [1].

This behavior is inconsistent with the expected behavior, which should format the date range starting from Monday to the following Sunday [2]. There is a known issue related to this in the Superset GitHub repository, and it has been mentioned as a bug fix in the changelog [3].

To address this, you might need to adjust the time grain expression in your Superset configuration or wait for an update that resolves this issue.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

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

No branches or pull requests

1 participant