Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

6.1 KB
Raw Blame
# Each automagic dashboard heuristic produces one dashboard and is primarily drawing
# from a single table (the "root table"). Other tables can be accessed via joins
# though.
#
# Heuristics are comprised of 3 sections: dimensions (defines fields to be used),
# metrics (aggregations), filters, and cards (cards to be displayed on the dashboard).

# Name of the dashboard
# You can reference the selected table in the title and description. A reference
#like this will be replaced by the table's (display) name.
title: Example exploration
description: Autogenerated metrics about [[GenericTable]].
# In general the file name of the heuristic is used to determine the type of table
# it applies to, but this can be overwritten by table_type field. For a list of
# available types see the namespace metabase.type.
applies_to: "*"

# Metrics
#
# Only aggregations ("metrics") defined here can be used in cards.
# Each metric is a map of metric name to metric definition which is again a map with
# two keys: metric (a MBQL expression) and score (between 0 and 100) used to
# determine the metric's importance. If score is omitted, 100 is assumumed.
# To reference dimensions defined within this heuristic use the form
# [dimension, DimensionName] (this is an extension to MBQL that is not available
# outside these heuristics definitions).
# One can also use shorthand where instead of a map, the definition is directly
# MBQL.
# Metrics can be overloaded. The highest scoring definition from among those that
# reference dimensions that match at least one field will be used.

metrics:
- TotalIncome:
    metric: [sum, [dimension, Income]]
    score: 90
# Shorthand
- TotalOrders: [count]

# Filters
#
# Each filter has the form of a map of filter name to filter definition,
# which is again a map with two keys: filter (a MBQL expression) and score (between
# 0 and 100) used to determine the metric's importance. If score is omitted, 100 is
# assumed. One can also use shorthand where instead of a map, the
# definition is directly filter MBQL.
# Filter can be overloaded. The highest scoring filter from among those that
# reference dimensions that match at least one field will be used.

filters:
  - Last30Days:
      filter: ["time-interval", [dimension, Timestamp], -30, day]

# Dimensions
#
# Dimensions define bindings to fields. A single dimension can match multiple
# fields. Primary mode of matching is by field type, but several refinements are
# available (name, where a foreign key points to). For a list of available field
# types see the namespace metabase.type.
# Each dimension has the form of a map of dimension name to dimension definition,
# which is again a map. One can also use shorthand where instead of a map, the
# definition is directly field_type.
# Dimensions can be overloaded. The highest scoring definition from among those that
# match at least one field will be used.

dimensions:
- Timestamp:
    field_type: CreationTimestamp
    score: 100
# Overloaded definition
- Timestamp:
    field_type: DateTime
    score: 90
# shorthand
- Income: Income
- Source: Source
- Long: Longitude
- Lat: Latitude
- UserFK:
    field_type: FK
    links_to: UserTable    # used to disambiguate FKs
- UserPK: UserTable.PK
# Match fields of type State from a joined table of type UserTable
- State: UserTable.State
- ProductCategory:
    field_type: ProductTable.Category
    max_cardinality: 10    # only capture fields with 10 or less distinct values
- BatchNum:
    field_type: Integer
    named: batch           # name pattern (regex)

# Groups

groups:
- OrderBreakdown:
    title: Some breakdown
    score: 50

# Cards
#
# Cards that go on the dashboard.
# If a dimension that matches multiple fields is referenced, multiple cards will be
# produced.
# Cards can be overloaded. The highest scoring definition from among those for which
# all dimensions referenced match at least one field will be used.
# Only the 9 highest scoring cards are shown. By default, cards are sized 6x4 grid
# units but this can be overridden.

cards:
- IncomeByMonth:
    visualization: line
    title: Sales by month
    description: Total income by month
    dimensions: Timestamp
    # 2 Y-axes
    metrics:
      - TotalIncome
      - TotalOrders
    score: 90
    width: 18       # full width of the dashboard
# Similar cards can be grouped together. Grouped cards will be displayed adjecent to
# one another and the highiest relevance score among them will be used for all.
- OrdersBySource:
    group: OrderBreakdown
    visualization: row
    title: Sales by source
    dimensions: Source
    metrics: TotalOrders
    filters: Last30Days
    # shorthand order_by clause. Same as:
    # order_by:
    #  - TotalOrders: descending
    # Multiple ordering criteria can be defined that way.
    order_by: TotalOrders
- OrdersByState:
    group: OrderBreakdown
    visualization:
      map:
        map.type: region
        map.region: us_states    #region can be one of: "world" or "us_states"
    title: Sales by state
    dimensions: State
    metrics: TotalOrders
    filters: Last30Days
    order_by: TotalOrders
- OrdersByProductCategory:
    # You can reference the selected field in the title. A reference like this will
    # be replaced by field's (display) name.
    title: Sales by product [[ProductCategory]]
    visualization: row
    group: OrderBreakdown
    dimensions:
      - ProductCategory
    metrics: TotalOrders
    order_by: TotalOrders
    # Same as SQL limit
    limit: 10
    score: 90
    height: 8     # double height
    filters: Last30Days
- OrdersByCoords:
      title: Distribution by coordinates
      metrics: TotalOrders
      # Multiple dimensions can be used
      dimensions:
        - Lat
        - Long
      score: 80
      visualization:
        map:
          map.type: pin
          # explicitly bind dimensions
          map.latitude_column: Lat
          map.longitude_column: Long
- Native:
     title: Native query
     # Template interpolation works the same way as in title and description. Field
     # names are automatically expanded into the full TableName.FieldName form.
     query: select count(*), [[State]]
            from [[GenericTable]] join [[UserTable]] on
            [[UserFK]] = [[UserPK]]
     visualization: bar