I have customers across the world and they use metabase dashboard to access critical data. We store the data in UTC, however we would like to show the reports to the users depending on their timezones.
For example, if a user in the USA queries Sales Data for 11th July 2020, they should see all the sales happenend on 11th July IN THEIR timezone. The data should be fetched as per their timezone and it should be displayed in their timezone.
How can I make it happen?
Timezones are some of the most difficult parts of Metabase. There’s an issue open about it:
https://github.com/metabase/metabase/issues/4284 - upvote by clicking on the first post
@flamber so that basically means the problem will take time to solve.
Is there any workaround using queries or anything like that?
@harshmaur You could probably hack something together, where you allow the user to set a filter value with the timezone and then parse that value in queries. It will definitely be a mess and difficult for the users to not make mistakes.
Another hack would be multiple database connections, where you define the timezone of each, and then only allow the users to see the database corresponding to their timezone. This would of course mean that you would have to create multiple dashboards and questions based on each database.
All in all, it’s going to be a horrible mess. Your best bet is to teach the users that all data is UTC and display a textbox on each dashboard describing that.
I like the idea of different database connections, can you explain how can I set report timezone for each database? From my understanding its only possible to set it account-wide for all databased connected to metabase.
@harshmaur That depends on the database type. It would be possible with the ones that has a changeable timezone variable through the Connection String. Otherwise you can probably do it through your database user, again, probably depends on the database type. Again, this is a hack, so you need to venture down that road with that mindset.
@harshmaur I don’t think you can do it with Postgres - believe it uses the JVM timezone. You would probably have to do something with filter variables. Or perhaps you can do something with a proxy.
Again, my recommendation: Tell your users that data is UTC.
That’s not perfect, but at least you’re not creating a massive hack.
Well, asking users to assume UTC is difficult as in my case the reports are really important.
I had another idea. I already know the timezone for the customers viewing the report. I can create a locked parameter of timezone and pass it myself for my customers and use that timezone for date queries. Do you think that would work?
@harshmaur Well, that’s totally different, when you’re embedding, then you have several other options (like locked parameters) and then you’re likely already writing queries in SQL, so that should be easy to do the conversion.
@flamber, well yes, our users will only see embedded dashboards.
I currently dont write anything in SQL yet. But yeah, I think I can write it and do the conversion.
Let me know if there is a way to avoid it. Its okay if there isnt any other way than writing SQL.
@harshmaur SQL all the way, when you have to get around limitations. Hack, hack, hack