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) starts from Sunday #971

Closed
mahedi0244 opened this issue Aug 17, 2016 · 13 comments
Closed

Time grain (week) starts from Sunday #971

mahedi0244 opened this issue Aug 17, 2016 · 13 comments
Labels
inactive Inactive for >= 30 days

Comments

@mahedi0244
Copy link

I am using caravel for a while and when I add a slice where the visualization type is "Time Series", I noticed that the week starts from Sunday by default. It can be changed easily to start the week on Monday, instead of Sunday. Is the caravel community thinking about adding a feature to select the start date or I can change it to Monday by default if you suggest.

@xrmx
Copy link
Contributor

xrmx commented Aug 18, 2016

@mahedi0244 nice finding! Is this on the python or js side? maybe we can have do it based on the locale?

@mahedi0244
Copy link
Author

@xrmx this is the part that I had to change and it seems like working
mahedi0244@7743cb2

@xrmx
Copy link
Contributor

xrmx commented Aug 21, 2016

@mahedi0244 so it looks like that just removing the - 1 DAY would be enough no?

Also note to self: this is db specific

@mahedi0244
Copy link
Author

mahedi0244 commented Aug 22, 2016

@xrmx
DAYOFWEEK(created_at) —>returns 1 for Sunday, 2 for Monday and so on.

DATE_SUB(created_at, INTERVAL DAYOFWEEK(created_at) - 1 DAY) —> will subtract days in such a way so it returns the previous Sunday

If I just replace "DAYOFWEEK(created_at) - 1 DAY" with “WEEKDAY(created_at) - 0 DAY” , the week will start on Monday, as WEEKDAY(created_at) returns 0 for Monday, 1 for Sunday and so on.

@xrmx
Copy link
Contributor

xrmx commented Aug 22, 2016

@mahedi0244 thanks for the explanation! but why - 0 day then is weekday is fine on its own?

@mahedi0244
Copy link
Author

@xrmx “WEEKDAY(created_at) DAY” will also work

@mistercrunch
Copy link
Member

mistercrunch commented Aug 30, 2016

Just add a new grain "week (starting Monday)". You then need to re-label the current one to "week (starting sunday)"

@daudryc
Copy link

daudryc commented Feb 9, 2017

I've been using superset for a while, just wondering if there is a feature on the dashboard that can alter time grain as we desired?

I mean the time grain config is the best, just wondering if we can also change it on dashboard view for various users.

@mistercrunch
Copy link
Member

Notice: this issue has been closed because it has been inactive for 438 days. Feel free to comment and request for this issue to be reopened.

@xrmx
Copy link
Contributor

xrmx commented Apr 23, 2018

@mistercrunch could you please reopen this?

@mistercrunch mistercrunch reopened this Apr 23, 2018
@ismael-benitez
Copy link

I need this feature too

@mistercrunch mistercrunch changed the title caravel time grain (week) starts from Sunday Time grain (week) starts from Sunday Aug 22, 2018
@mistercrunch
Copy link
Member

mistercrunch commented Aug 22, 2018

We have this for some database, it's just a matter of adding the proper expression for your database engine. Here's how it's done on Presto:
https://github.com/apache/incubator-superset/blob/master/superset/db_engine_specs.py#L718

Which engine are you all interested in? Note that the key used in the time_grain_functions should match the ones defined here: https://github.com/apache/incubator-superset/blob/master/superset/db_engine_specs.py#L69-L72

@stale
Copy link

stale bot commented Apr 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. For admin, please label this issue .pinned to prevent stale bot from closing the issue.

@stale stale bot added the inactive Inactive for >= 30 days label Apr 10, 2019
@stale stale bot closed this as completed Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Inactive for >= 30 days
Projects
None yet
Development

No branches or pull requests

5 participants