I have a table of a lot of items’ sales per location (pivoted). Can I group some of the items in the column.
Instead of having jeans, t-shirts, baseball caps(headwear), beanies (headwear), sweaters, visors (headwear) I’d like the column to be jeans, t-shits, sweaters, headwear (all items).
Thanks for your help, probably an easy one!
Are you a developer on this Looker instance? (Do you have access to the “Develop” tab at the top of the page?)
If so, you can create a new dimension using a CASE statement in the sql: parameter. It would look something like:
dimension: new_category {
type: string
sql:
CASE
WHEN ${your_category_column} IN ('baseball caps', 'beanies', 'visors') THEN 'headwear'
ELSE ${your_category_column}
END ;;
}
The reason I’d do this in the sql: parameter instead of using the built-in case: parameter is that the built in case parameter won’t let you use substitution syntax (the ${column} syntax) to label things, which is a pain when you have more than a handful of columns to bucket.
Unfortunately, I’m not sure if there’s any way to do this from the explore itself. Hope that helps!
P.S. If you want to overwrite the original column so you see “Category” in the explore, you can add label: “Category” to this new dimension and add hidden: yes to the original category dimension