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.
β 6.4. CASE Functions with Multiple Clauses
β 6.5. Tips for Editing Formulas in Looker Studio
β 6.6. Using CASE Function for Cleaning Data
β 6.7. Order of WHEN Clauses in CASE Function
β 6.8. Returning Expressions in CASE Functions
β 6.9. Using CASE to Extract URL Query Parameters
β 6.10. Mixing Dimension & Metrics in CASE
π© Receive my weekly Looker Studio tips
π₯Β Subscribe to my YouTube channel
π Connect with me on LinkedIn