Chapter 14: Working with Dates, Embedding Content, and Extracting Data
14.4. WEEKDAY() Function
In this lesson, we will explore the WEEKDAY() function in Looker Studio, which allows you to extract and display the day of the week from a given date. This can be useful in various analyses such as identifying popular days for a website, planning staff schedules for a call center, or tracking site activity across days of the week.
Extracting Day of the Week
To extract the day of the week from a date, use the WEEKDAY()
function:
WEEKDAY(date)
This function returns a number between 0 and 6, where Sunday is represented by 0 and Saturday by 6.
Displaying the Name of the Day
By default, the WEEKDAY() function does not return the name of the day, only its index. To show the actual day name, you must use a CASE
statement to map the numerical output to the corresponding day name:
CASE WHEN WEEKDAY(date) = 0 THEN "Sunday"
WHEN WEEKDAY(date) = 1 THEN "Monday"
...
WHEN WEEKDAY(date) = 6 THEN "Saturday"
END
This CASE
statement checks the output value of the WEEKDAY()
function and returns the corresponding name of the day for each value.
Considerations
Although Looker Studio doesn't support lookup tables, you can use functions like WEEKDAY()
and CASE
to achieve similar objectives. Using these functions, you can create customized analyses and visualizations based on your data, allowing you to extract valuable insights from your data set.
Remember to take advantage of the flexibility provided by Looker Studio functions to enhance your data analysis and presentation. Understanding these functions and their applications allows you to provide better insights and optimize your operations based on relevant metrics.
📩 Receive my weekly Looker Studio tips
🖇 Connect with me on LinkedIn