posthog icon indicating copy to clipboard operation
posthog copied to clipboard

Ability to configure first day of the week

Open lsmith77 opened this issue 3 years ago • 2 comments

Is your feature request related to a problem?

Right now Posthog seems to default to Sunday being the first day of the week. Many countries (especially in Europe) use Monday as the first day of the week. As such it is slightly confusing to have Sunday as the first day of the week.

Describe the solution you'd like

Ability to configure on an organization and/or project level if the first day of the week should be Monday.

Describe alternatives you've considered

Additional context

Thank you for your feature request – we love each and every one!

lsmith77 avatar Jan 31 '22 07:01 lsmith77

Actually .. it seems like on the insights charts it already defaults to Monday. I noticed it using Sunday in one place a few days ago but now that I submitted the feature request I am not sure where I saw it. It was a date selector .. somewhere in the UI.

lsmith77 avatar Jan 31 '22 07:01 lsmith77

Came up as a support hero request today.

cc @mariusandra - saw your todo in the new LemonCalendar. This probably would love some attention generally.

macobo avatar Sep 19 '22 12:09 macobo

it seems like it now does this based on the IP address: https://github.com/PostHog/posthog/blob/master/posthog/utils.py#L1111

but it would be useful to also support explicit choice (f.e. for remote teams) but more importantly in the API to be able to fetch insights data to present to world-wide users (ie. where the IP would be the IP of the server).

https://posthogusers.slack.com/archives/C01GLBKHKQT/p1669026521557419?thread_ts=1669021175.100369&cid=C01GLBKHKQT

lsmith77 avatar Nov 21 '22 11:11 lsmith77

This makes a lot of sense! Unfortunately it's not a "quick fix"... yet this keeps coming up often enough that we can't ~ignore it~ be busy doing other stuff forever :).

mariusandra avatar Nov 22 '22 07:11 mariusandra

this is now supported as a project setting: https://posthog.com/changelog/2023#customize-whether-weeks-start-on-monday-or-sunday

I would have prefered if it would be supported on an insight level.

lsmith77 avatar Sep 21 '23 10:09 lsmith77

so looks like HogQL might hold the answer for some use cases at least https://posthogusers.slack.com/archives/C01GLBKHKQT/p1695315958472839?thread_ts=1695315945.437619&channel=C01GLBKHKQT&message_ts=1695315958.472839

Yes, you can change the settings to break down your data by weeks starting on Thursday and ending on Wednesday. PostHog's date and time filters provide flexibility in customizing how you group and analyze your data.

To break down your data by weeks starting on Thursday and ending on Wednesday, you can use the HogQL function toDayOfWeek(timestamp). This function returns the day of the week for a given timestamp, where Sunday is 1, Monday is 2, and so on.

To achieve your desired week breakdown, you can use the following HogQL filter:

toDayOfWeek(timestamp) >= 5 AND toDayOfWeek(timestamp) <= 11

In this filter, the condition toDayOfWeek(timestamp) >= 5 ensures that the week starts on Thursday (as Thursday corresponds to 5), and the condition toDayOfWeek(timestamp) <= 11 ensures that the week ends on Wednesday (as Wednesday corresponds to 11).

By applying this filter to your data analysis queries, you can break down your data based on weeks starting on Thursday and ending on Wednesday.

Please note that this is just one example of how you can customize the week breakdown. You can adjust the filter according to your specific requirements.

If you need any further assistance or have more PostHog-related questions, feel free to ask!

https://github.com/PostHog/max-ai#disclaimer 

lsmith77 avatar Sep 21 '23 21:09 lsmith77