User Guide Getting Started Help Center Documentation Community Training
New LookML
Old LookML
New LookML
Looker
  
English
Français
Deutsch
日本語
order_by_field

Using order_by_field incorrectly can cause inconsistent, confusing behavior for users.

Usage

view: view_name {
  dimension: field_name {
    order_by_field: field_name
  }
}

Hierarchy

order_by_field

Possible Field Types

Dimension, Dimension Group

Accepts

A field name

Definition

The order_by_field parameter enables you to use the sort order from a dimension or dimension group on another field of the same type.

For example, you might have a table that contains both a status_id and a status_name column. When a user sorts by Status Name in the UI, you might want the names to appear in the order of the status ID, and not the alphabetical order of the names.

If there is one and only one status_id for each status_name, you could write:

dimension: status_name { sql: ${TABLE}.status_name ;; order_by_field: status_id }

There should be a 1:1 relationship between a field and its order_by_field field, so that the grouping characteristics of both fields are exactly the same. If you do not ensure this, sorting can appear to be random to users.

Top