View YAML: Fields

You can extensively customise your views in YAML. Below is the schema and some examples to get you started.

Fields Schema

Field nameDescription
fieldsA list of fields that are available in the view.
fields[*].nameThe name of the field. Must be unique within this view.
fields[*].labelA user-friendly label for the field. This is what is displayed in the UI, and defaults to the name. Optional.
fields[*].descriptionA description of the field. This is shown in the UI when the field is hovered over. Optional.
fields[*].expressionThe SQL expression that defines the field, defined in the dialect detailed here. Defaults to the name of the field. Optional.
fields[*].typeThe type of the field. This can be one of string, number, integer, date, or boolean. If unspecified, this defaults to string. Optional.
fields[*].groupPlaces the field within a group of this name in the UI. Optional.
fields[*].primary_keyWhether or not the field is a primary key. Optional.
fields[*].hiddenWhether or not the field is hidden. Useful for joining keys you don't want to expose in the UI. Optional.
fields[*].aggregatesA list of aggregates to apply to the field: count, count_distinct, sum, avg, median, mode, max, min, stddev_pop, stddev_samp, var_pop, var_samp, null (where null means no function is applied). These will appear as a collapsible group in the UI. Optional.
fields[*].timeframesA list of timeframes by which to group the field: year_trunc, quarter_trunc, month_trunc, week_trunc, day_trunc, hour_trunc, minute_trunc, second_trunc, year, quarter, month, week, day_of_year, day_of_month, day_of_week, hour, minute, second, null (where null means no function is applied). These will appear as a collapsible group in the UI. Optional.
fields[*].formatThe default format for this field when used in visualizations. Optional.
fields[*].format.typeThe format type. This can be one of raw, currency, number, percentage, scientific, long_date, short_date, or custom_date.
fields[*].format.currencySpecifies the currency to use when formatting numbers as currency (e.g., USD, EUR, GBP, AUD, CAD, CHF, JPY, CNY). For a full list of currency codes see here. Optional.
fields[*].format.display_unitsAllows display units like thousands, millions, billions, or trillions. Optional.
fields[*].format.negative_valuesDefines the style for negative numbers, either accounting or standard. Optional.
fields[*].format.thousand_separatorA boolean indicating whether to use a thousand separator. Optional.
fields[*].format.decimalsSets the number of decimal places for numeric values. Optional.
fields[*].format.prefixAdds a prefix to the formatted value. Optional.
fields[*].format.suffixAdds a suffix to the formatted value. Optional.
fields[*].format.yearDetermines the year format, either numeric or 2-digit. Optional.
fields[*].format.quarterSpecifies the quarter format, which can be long, short, or numeric. Optional.
fields[*].format.monthDefines the format for month, options include numeric, 2-digit, long, short, or narrow. Optional.
fields[*].format.dayDetermines the format for day, either numeric or 2-digit. Optional.
fields[*].format.weekdayDefines the weekday format, either long, short, or narrow. Optional.
fields[*].format.hourSets the hour format, either numeric or 2-digit. Optional.
fields[*].format.minuteSpecifies the minute format, either numeric or 2-digit. Optional.
fields[*].format.secondSets the second format, either numeric or 2-digit. Optional.
fields[*].format.fractional_second_digitsSpecifies the number of fractional seconds (1, 2, or 3). Optional.

Example uses

Using expression, type and aggregates

Loading code...

Custom calculated fields look no different to predefined fields in the canvas UI.

Using timeframes

Loading code...

Here’s how this looks in the canvas.

Using description

Loading code...

In the canvas UI, descriptions appear in tooltips when you hover over the field with your cursor.

Using group

Loading code...

In the canvas UI, field groups will appear as expandable sections that reveal their fields when clicked.

Loading...