I have a google sheet full of donation transactions like this
name, date, amount
And I built a simple Looker table showing the aggregate donations for each ‘name’ over some period of time like this:
name, total_donations
I’d like to have a third column (bucket) with rules like this:
if (
Amount >= 2500, "Gold",
if Amount >= 1000, "Silver",
if Amount >= 250, "Bronze",
if Amount >= 50, "Friend",
"N/A"
)
)
)
)
However, the above calculated field is applied per-row of the raw data … how can I apply the same logic to the aggregate SUM of Amount?
Couple of comments :
1) if you want to keep Looker at name grain then the bucket logic would have to be put in the stage where you are aggregating the data to the name grain
2) An alternate is to keep Looker at name, week grain (which will allow you to create the buckets in Looker) and then create measures within Looker to get the total_donation. That gives people the flexibility to see details if they want to
I would use Table Calculation for it because it's evaluated after the SQL returns data table (2nd layer). However, if you want to make this grouping persistent, then you would need to create a model first or a derived table and then add the grouping.