Views are a collection of fields (measures and dimensions) along with metadata, providing a flexible and efficient way to organize and manage your data. Views can be initialized quickly from database tables or canvas cells. Each view is stored in a separate YAML file, ensuring clarity and ease of customization.
View YAML schema
The schema for view definitions is displayed next to the YAML editor in Count. Expand the section below for an example view definition.
Show the view YAML schema
# This is the name of the view as it appears in code
name: events
# Optional caching and scheduling settings for the view
caching:
duration: 360000
schedule: 0 0 * * *
# The source query of the view - think of dependencies like cells in a canvas
source:
connection: null
query: SELECT * FROM events_df
dependencies:
- name: events_df
query: SELECT * FROM `count-data`.demo_data.events
connection: 7zoODN2N9UI
# The fields that are exposed from this view
fields:
# The name of the field as it appears in code
- name: event_id
# An optional custom label for the field to display in the low-code UI
label: Event ID
# An optional custom description for the field to display in tooltips
description: 'unique identifier for each event'
# Change the field type to update the available aggregation options
type: integer
# Define a primary key for better joining between views
primary_key: true
# Optionally decide which aggregations are available for this field
aggregates: [count_distinct, sum, min, max, avg,]
- name: user_id
label: User ID
description: 'unique identifier for each user'
type: integer
- name: timestamp
label: Timestamp
description: 'date breakout options'
type: date
# Optionally decide which temporal options are available for this field
timeframes: [year_trunc, quarter_trunc, month_trunc, week_trunc, day_trunc, day_of_week]
- name: events_per_user
label: Events per User
description: 'number of events per user'
expression: count(distinct event_id) / count (distinct user_id)
type: number
- name: event_type
label: Event Type
description: 'type of event'
type: string
- name: workspace_id
label: Workspace ID
description: 'unique identifier for each workspace'
type: integer
- name: event_details
label: Event Details
description: 'details of event'
type: string
Building Views
The next pages will guide you through creating and customizing your views.
Creating Views– Learn how to set up new views to organize your data effectively.
Customizing Views – Adjust and refine your views to fit your specific needs.