tegorizations are a way to categorize elements of your data. You can then use the categorizations inside of your SQL. This gives your team an easy way to keep all of your categorizations in one place and outside of raw SQL.
You can find categorizations for your clients by clicking the Categorizations in the top nav bar.
Required Dimensions & Metrics - Fields that your function will use. Adding a required dimension makes it available in the "IF" part of the query.
Rule - A rule contains a Field, Operator, Value and Answer.
Default Value - If none of the values match, a default value is then applied.
Using Categorizations inside of Redshift
Categorizations inside of redshift are very easy to use and do not rely on datasources. They are created as functions.
For instance, the following categorization named channel inside of the playground client:
would be a reference in SQL as:
select playground.channel(campaignName) from pmg.datasource;
The field name does not have to match the UI. Since the categorizations are not datasource dependent, you can use any datasource column.
select playground.channel(campaign_name) from pmg.datasource2; select playground.channel(campaignName) as channel, SUM(impressions) from playground.adwords_datasource GROUP BY channel;
Using Categorizations inside of BigQuery
BigQuery categorizations very similar to Redshift
select playground.channel(campaign_name) from playground.datasource
Make a new categorization and then get a clean categorization template by clicking on the Download Template button.
You should get a CSV template with a header:
DIM_METRIC_NAME - The dimension or metric name
OPERATOR - the function you want to apply to your current value with a value you want to compare to
VALUE - the comparing value that will go against the values from reports
THEN - the resulting value; skip if this is an and statement
AND - fill in and in the excel cell if using an and statement
To upload the bulk sheet, just drag/drop the file onto the RULES area.
Bulk Sheet Example
I have a bulk upload file that will look at campaign names in a report and give a new value where the campaign name is active on.
If the names louisiana AND texas, then I want to have a value south in a new column.
Publishing a Categorization
To publish a categorization, hit the Publish button. It will then be available to use in SQL.
When using delimiters, you can specify the values in fields, categorization values and default values.
To setup a categorization, select the field next to the category field:
You can then use the categorization or default values with a colon(:) plus a number (starting with 0).