Issue with aggregation & date range when using case when statement

qjf
Bronze 1
Bronze 1

I have some sample data HERE  that feeds into the Looker Dashboard HERE. The sample data consists of campaign data from one account broken out by their daily CPC. 

In Looker, I added a customer field called 'CPC Alert Type' which is a simple CASE WHEN statement, to label when the cpc falls into certain ranges ('High', 'Medium', 'Low').  

What I would expect is when I select a date range, I would get back a single row with the average cpc for that date range and then label from 'CPC Alert Type' be applied to that average. 

What seems to be happening is that the CASE WHEN is looking for an instance of each range for the date range, so instead of getting back one row, I'm getting back a row for ('High', 'Medium', 'Low').

Any help on how to remedy this would be greatly appreciated. Thank you. 

0 1 137
1 REPLY 1

CPC Alert Type is being created as a dimension. This occurs before any aggregation (e.g., averaging the CPC). You'll want to either create a new measure for CPC alert that runs a case statement (or equivalent) on the averaged CPC or to create a secondary stage calculation (like a table calculation) that does the same.

Top Labels in this Space