Context
Instructions
First create a User Attribute to drive the date formats. In our example, we will have some US based users and some EU based users.
Create a new dimension for your formatted date. Then use the html parameter to format your date in a liquid if statement that references your user attribute.
This is how both of these dimensions will appear to an end user with the eu value in their date_location user attribute.
Next we need to think about how this dimension will appear to our user in the explore. Instead of two separate dimensions, we want our new date dimension to replace the existing Date timeframe in the Created Date dimension group. This will also allow us to use one dimension in the same report that will have different formatting depending on the user.
Remove the Date timeframe from the Created Date dimension group
Add type, group_label, and label parameters to the new formatted dimension
Now this is how the dimension group appears to an eu user:
Thanks for the suggestion.
Is there a way to save and re-use the same date format localization logic across different across different dimensions?
In more detail, let's say we are already tracking the user locale as an user attribute and we know that each user locale corresponds to a unique way of displaying date and time, are we still going to be required to write the same sql and/or html parameter logic every time we want to produce a localised time format dimension in our Looker project? Or could we save the logic once and then apply whenever needed?
I'm not aware of any other way to accomplish date format localization. It must be written into the LookML dimension parameters.
Thanks for taking the time to reply, Emily.