show

show, keyword

Displays a dashboard tile. Every script must emit at least one tile.

Syntax overview

The general shape of a show statement is:

show table "my title" a1c2 slices: SX { tileColor: tomato; backgroundColor: "#fdad31" } with
  Items.Category as "My category"
  Items.Supplier as "My supplier"
  sum(Items.StockOnHand) as "Stock on hand"
  sum(Items.StockOnHand * Items.BuyPrice) as "Stock value"
  group by [Items.Category, Items.Supplier]
  order by [Items.Category, sum(Items.StockOnHand * Items.BuyPrice)] desc

The title is optional. When omitted, the placement, slices: option, or StyleCode block follows the tile type directly:

show scalar with sum(Items.StockOnHand)
show scalar a1b1 { tileColor: tomato } with sum(Items.StockOnHand)

The elements that compose a tile are:

Named tiles and regions

A show statement can be assigned to an identifier. This is primarily used with show region, but it also applies to the other tile types.

overview = show region { ..6, ..12 }

total = show scalar "Total" { ..3, ..8 in overview } with 42

cta = show button "Open docs" { href: "https://docs.lokad.com/" }

Named regions can be referenced with in overview. Show identifiers must be unique within the script.

Grouping and ordering

The expressions passed after with are aligned into a table for the tile. You can add group by and order by statements at the end of that list:

A single order by expression can also be a tuple. The tuple elements are used as successive sort keys:

show table "my table" with
  T.X
  T.Y
  T.Z
  order by [T.X desc, T.Y]
show table with
  T.A
  T.B
  order by [(T.A, T.B)]

Envision also offers a concise inline form for simple tiles:

show table with T.X, T.Y, T.Z

Loops inside with

A loop can appear inside the with body of a tile. In that context, each iteration contributes columns or tile-specific sub-blocks to the surrounding tile. The loop does not create nested tiles.

This pattern is useful when the tile repeats the same structure several times, for example one column per month in a rolling monthly report:

keep span date = [date(2024, 1, 1) .. date(2024, 6, 30)]

table Items[item] = with
  [| as item |]
  [| "shirt" |]
  [| "hat" |]

table Sales = with
  [| as Item, as Date         , as Qty |]
  [| "shirt", date(2024, 1, 15), 120 |]
  [| "shirt", date(2024, 2, 15), 140 |]
  [| "shirt", date(2024, 3, 15), 135 |]
  [| "shirt", date(2024, 4, 15), 150 |]
  [| "shirt", date(2024, 5, 15), 155 |]
  [| "shirt", date(2024, 6, 15), 160 |]
  [| "hat"  , date(2024, 1, 15),  80 |]
  [| "hat"  , date(2024, 2, 15),  95 |]
  [| "hat"  , date(2024, 3, 15), 110 |]
  [| "hat"  , date(2024, 4, 15), 105 |]
  [| "hat"  , date(2024, 5, 15), 115 |]
  [| "hat"  , date(2024, 6, 15), 125 |]

table Monthly[key] = by [Sales.Item, month(Sales.Date)]
Monthly.Item, Monthly.Period = key
Monthly.Qty = sum(Sales.Qty)

latest = max(Month.month)

show table "Last 6 months" with
  item as "Item"
  loop k in 0..5
    Monthly.Qty[item, latest - 5 + k] as text(latest - 5 + k)

The tile renders one row per item and one generated column per month, without spelling out each month explicitly:

Item 2024-01 2024-02 2024-03 2024-04 2024-05 2024-06
shirt 120 140 135 150 155 160
hat 80 95 110 105 115 125

Example

table Sales = with
  [| as Region, as Units |]
  [| "Europe", 100 |]
  [| "Europe", 125 |]
  [| "North America", 1000 |]
  [| "North America", 75 |]

show label "Sales demo"
show scalar with sum(Sales.Units)

show table with
  Sales.Region
  sum(Sales.Units) as "Units"
  group by Sales.Region

show barchart "Units by region" with
  sum(Sales.Units) as "Units"
  group by Sales.Region

The show table tile renders:

Region Units
Europe 225
North America 1075

Remarks

The tile type (such as scalar or table) controls how vectors are rendered. If provided, the tile title must be a scalar text value and can be computed. Placement, slices:, and StyleCode can be used with or without a title. The with block is required for all tile types except button and label. When a loop appears inside with, its body follows the rules of the surrounding tile body. In particular, the loop may repeat columns or tile-specific sub-blocks, but it still cannot introduce nested show statements. Conversely, if blocks remain unavailable inside show bodies. For calendar tables, literal lags such as [-1] remain available, but loop-driven month generation typically relies on Month.month arithmetic and explicit lookups. Some tile types add placement-specific constraints. For example, barchart accepts multiple value expressions with region placement, while legacy Excel-like coordinates keep the single-series form.

See also

Below is the complete list of tile types supported by Envision:

User Contributed Notes
0 notes + add a note