Start Here

Run these examples in an Envision project in your Lokad account. You will build your first dashboard tiles and load the sample dataset.

Scripts are indentation-sensitive: blocks under with or where are indented by two spaces. Tiles appear when you use show, and table columns are referenced as Table.Field.

Table of contents

Run Your First Envision Script

  1. Create an Envision project in your Lokad account and open its code editor.
  2. Paste the script below and press Run.
  3. You should now see a scalar tile labeled “Session is running” and a table with three rows.
preview = show region { 1..8, 1..15 }

table Greeting = extend.range(3) // 3 lines: N = 1,2,3
Greeting.Step = "Step \{Greeting.N}"
Greeting.Value = Greeting.N * 2

show scalar "Session is running" { .., 1..3 in preview } with count(Greeting.*)
show table "First table" { .., 5..12 in preview } with
  Greeting.Step
  Greeting.Value

The preview shows the expected output.

If the tiles render, your environment is ready for the rest of the tutorials. Re-run the script after changing Greeting.Value (try Greeting.N^2) to get used to the quick feedback loop.

Load the 1-Echelon 2017 Sample Dataset

  1. Download the 1-echelon 2017 dataset and upload the files to /sample in your Lokad account.
  2. Paste the script below and press Run.
  3. You should now see a scalar with the SKU count and a table showing the last 30 days of orders.
read "/sample/Lokad_Items.tsv" as Items[id] with
  "Id" as id : text
  Name : text
  Category : text
  StockOnHand : number

read "/sample/Lokad_Orders.tsv" as Orders expect [id, date] with
  "Id" as id : text
  "Date" as date : date
  Quantity : number
  NetAmount : number

latestDate = max(date)

show scalar "SKUs loaded" with count(Items.*)

where date >= latestDate - 30
  show table "Orders in the last 30 days" with
    Orders.id
    Orders.date
    Orders.Quantity
    Orders.NetAmount { unit:"$" }

If the script cannot find the files, check that you uploaded them to /sample.

Display a Table Tile and a KPI Tile

Build a tiny dataset inline and surface it as both a KPI (scalar) and a table tile.

  1. Paste the script and run it.
  2. You should now see a KPI showing total revenue and a table listing each SKU.
table Orders[sku] = with
  [| as sku, as Qty, as Price |]
  [| "A-001", 4, 12.5 |]
  [| "B-010", 2, 18.0 |]
  [| "C-003", 6,  9.0 |]

Orders.Amount = Orders.Qty * Orders.Price

show scalar "Total revenue" { unit:"$" } with sum(Orders.Amount)

show table "Order lines" with
  Orders.sku
  Orders.Qty
  Orders.Price { unit:"$" }
  Orders.Amount { unit:"$" }

Change Orders.Price for one item and re-run to see the KPI and table update together.

Plot Weekly Sales with a Line Chart

Create a short date range, add some synthetic sales, and plot the weekly totals to get used to time-aware tiles.

  1. Paste the script and run it.
  2. You should now see a line chart with nine weekly points (the last week is partial).
keep span date = [date(2024, 1, 1) .. date(2024, 2, 29)] // 60 days

Day.Sales = random.poisson(20 into Day)
Week.Sales = sum(Day.Sales)

show linechart "Weekly sales" { 1..8, 1..14 } with
  Week.Sales { unit:"units" }

Hover over the line to inspect each weekly total. This preview shows one precomputed sample.

Adjust the date range or the random.poisson parameter and re-run to see how quickly charts update.