Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrosell/edb3a89127f49edc8a08bbe18b35bfbd to your computer and use it in GitHub Desktop.
Save jrosell/edb3a89127f49edc8a08bbe18b35bfbd to your computer and use it in GitHub Desktop.
Google Looker Studio snippets to help in the creation of helper date dimensions in string format.
// Create my_date_month custom field from existing date field my_date
MONTH(my_date)
// Create my_date_YYYYMM ucstom field from existing numeric field my_date and my_date_month
CASE
WHEN my_date_month=1 THEN CONCAT(YEAR(my_date),'01')
WHEN my_date_month=2 THEN CONCAT(YEAR(my_date),'02')
WHEN my_date_month=3 THEN CONCAT(YEAR(my_date),'03')
WHEN my_date_month=4 THEN CONCAT(YEAR(my_date),'04')
WHEN my_date_month=5 THEN CONCAT(YEAR(my_date),'05')
WHEN my_date_month=6 THEN CONCAT(YEAR(my_date),'06')
WHEN my_date_month=7 THEN CONCAT(YEAR(my_date),'07')
WHEN my_date_month=8 THEN CONCAT(YEAR(my_date),'08')
WHEN my_date_month=9 THEN CONCAT(YEAR(my_date),'09')
WHEN my_date_month=10 THEN CONCAT(YEAR(my_date),'10')
WHEN my_date_month=11 THEN CONCAT(YEAR(my_date),'11')
WHEN my_date_month=12 THEN CONCAT(YEAR(my_date),'12'
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment