order_by_field

LookML
Version

On this Page
Docs Menu

Go to Field Parameter List

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

Definition

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

For example, you might have a table that contains both a Status Id and Status Name column. When a user sorts the Status Name column, 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

Note: 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 totally random to end users.

Still have questions?
Go to Discourse - or - Email Support
Top