Chapter 6: Grouping & Categorizing Data
6.3. Grouping 404 Pages with CASE Function
In this demo we will see how the CASE() function works as we utilize it to identify web pages with 404 errors.
Let's examine another example of the CASE function to understand its use better.
Suppose you want to identify 404 pages in your data. A 404 page has the page title "Page unavailable." Using the CASE function, you can categorize pages as either "404" or "Not 404."
Here's the CASE function to achieve this:
CASE
WHEN PageTitle = 'Page unavailable' THEN '404'
ELSE 'Not 404'
END
In this example, if the page title is "Page unavailable," the function returns "404." Otherwise, it returns "Not 404." Note that you could also use the IF() function in this case, as there are only two categories:
IF(PageTitle = 'Page unavailable', '404', 'Not 404')
This IF function would produce the same result as the CASE function in this example. Using the CASE function here helps us understand how it works, even though it's not strictly necessary for this specific scenario.
📩 Receive my weekly Looker Studio tips
🖇 Connect with me on LinkedIn