Time grain (week) starts from Sunday
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.
@mahedi0244 nice finding! Is this on the python or js side? maybe we can have do it based on the locale?
@xrmx this is the part that I had to change and it seems like working https://github.com/mahedi0244/caravel/commit/7743cb2001ed6fde3b47778b0702f16ed14d1989
@mahedi0244 so it looks like that just removing the - 1 DAY would be enough no?
Also note to self: this is db specific
@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.
@mahedi0244 thanks for the explanation! but why - 0 day then is weekday is fine on its own?
@xrmx “WEEKDAY(created_at) DAY” will also work
Just add a new grain "week (starting Monday)". You then need to re-label the current one to "week (starting sunday)"
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.
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.
@mistercrunch could you please reopen this?
I need this feature too
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
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.