Dashboards, slicing

Slicing defines multiple dashboard variants and lets the user pick which one is shown. This page focuses on the language mechanics behind slices and how they affect tiles.

Table of contents

Slices are defined once per script

Slicing starts by creating a dedicated Slices table with slice by. The table is upstream of the data it slices, and the definition can appear only once in a script. The title: option sets the name shown in the slice selector.

table Products[pid] = with
  [| as pid, as Name, as Price |]
  [| "P-01", "Widget", 12.0 |]
  [| "P-02", "Gizmo", 18.0 |]

table Slices[slice] = slice by pid title: Products.Name

show table "Selected product" sliced with
  Products.Name
  Products.Price { unit: "$" }

show scalar "All products" with count(Products.*)

The sliced keyword recomputes tiles

Tiles with sliced are recomputed for the active slice. Tiles without it are global and show the same content regardless of selection. The slice dimension connects the data to its slices; a tile that displays rows needs that dimension on its data table. Usually, slice by adds it as a secondary dimension to the source table. It can also be the primary dimension of Slices itself, or part of a cross table such as cross(Slices, Month). A product-by-month cross table can therefore keep all months visible while showing only the selected product. See slices for the full rules.

Slice selectors are tiles too

The selector UI is part of the dashboard. Use slicepicker for a drop-down or slicetree for a hierarchy. These tiles make the slice context visible next to the data it controls.

table Products[pid] = with
  [| as pid, as Category, as Name, as Price |]
  [| "P-01", "Hardware", "Widget", 12.0 |]
  [| "P-02", "Hardware", "Gizmo", 18.0 |]
  [| "P-03", "Accessories", "Case", 6.0 |]
  [| "P-04", "Accessories", "Cable", 4.0 |]

table Slices[slice] = slice by pid title: Products.Name subtitle: Products.Category

show slicetree "Products" a1b6 with
  slice

show table "Selected product" c1f6 sliced with
  Products.Name
  Products.Category
  Products.Price { unit: "$" }

See also