alias

Usage

view: view_name {
  dimension: field_name {
     alias 
 : 
 [ 
 old_field_name 
 , 
 old_field_name 
 , 
... ] 
  }
}
Hierarchy
alias
Possible Field Types
Dimension, Dimension Group, Measure, Filter, Parameter
Accepts
A square-bracketed list of field names

Definition

The alias parameter provides alternative names for a field that might appear in the URL for a query. It can be useful in cases when field names in a model change, but you have pre-existing URLs to queries that you want to keep functioning.

The following example shows how you could change a field named count to the new name number_of_items , without breaking any existing queries that refer to count .

 measure: number_of_items {  # the new name
  alias: [count]            # the old name
  type: count
} 

You can also provide multiple aliases, in case you rename a field multiple times. For example, if you renamed the number_of_items field from the previous example to number_of_order_items , you could use the following:

 measure: number_of_order_items {   # the new name
  alias: [count, number_of_items]  # the old names
  type: count
} 

To use alias with a dimension group, change the dimension group name, not every field in the dimension group. For example, to rename the dimension group created_date to order_date :

 dimension_group: order_date {  # the new name
  alias: [created_date]        # the old name
  type: time
  timeframes: [time, hour, date, week, month, year, hour_of_day, day_of_week, month_num, raw]
  sql: ${TABLE}.created_at ;;
} 

Note that alias is used only to keep URLs functioning. It should not be used when referencing fields in LookML. For example:

 measure: number_of_items {
  alias: [count]
  type: count
}
measure: percent_items_sold {
  sql: ${sold_items} / ${number_of_items} ;; # will work because there
  type: number                               # is a measure named number_of_items
}
measure: percent_items_sold {
  sql: ${sold_items} / ${count} ;; # will NOT work because you
  type: number                     # should not use alias names in LookML
} 

Things to know

If you alias a field as a name already taken by another field, the LookML Validator will return an error.

Design a Mobile Site
View Site in Mobile | Classic
Share by: