SOP-ADVANCED-QUERY-DATALOG-1.0Rev. v1.0··2026-05-22

Advanced Query (Datalog)

When one filter line isn't enough — rules that join, derive and condense

PROCEDURE
  1. 1
    Insert a query block and switch into Datalog mode.
    TOOLS
    mium
    DURATION10 sec
    Checkpoint: An empty :find/:where block is ready.
  2. 2
    Set :find to the value you want, fill :where with conditions — one per line.
    TOOLS
    Datalog editor
    DURATION60 sec
    Checkpoint: The rule returns a first match set.
  3. 3
    Connect variables across blocks (join) or aggregate with count/sum.
    MATERIALS
    Variables ?x
    DURATION60 sec
    Checkpoint: The report joins several criteria.
  4. 4
    Save the rule as a named view; it recomputes on every change.
    MATERIALS
    Page or dashboard
    DURATION15 sec
    Checkpoint: The saved rule appears and refreshes live.
BACKGROUND

A Simple Query filters one property and becomes a view. But the moment you want to connect two things — open tasks from a quarter's meetings, grouped by project — the filter line runs out. Datalog starts exactly there: you describe the relationship as a rule, and mium derives the rest.

Where the filter line runs out

A filter line checks blocks one by one against fixed criteria. It can't join across blocks, derive nothing and add nothing up. Multi-criteria reports you'd otherwise click together by hand from several views — and maintain them the same way. Datalog turns that around: one rule that describes the relationships, and an engine that evaluates it.

Anatomy of a rule

A Datalog rule has two parts: :find says which value you want to see, :where lists the conditions — one per line. Variables such as ?task connect the lines; where the same variable appears more than once, that is a join.

[:find ?task
 :where
 [?task "type" "task"]
 [?task "status" "offen"]
 [?task "von-meeting" ?m]
 [?m "tag" "q3"]]
;; offene Aufgaben aus Q3-Meetings — ein Join über ?m

5 building blocks for Advanced Query

  1. The rule describes the goal (:find), not the search path — you say what, not how.
  2. Each :where line is a condition; shared variables connect them into a join.
  3. Aggregates condense: count, sum, max, min, avg over the matched set.
  4. A rule is reusable — name it, and it becomes a view for the whole team.
  5. Set limits: recursive or unbounded joins need a bound, or the evaluation gets expensive.

Example: counting open tasks per project

[:find ?projekt (count ?task)
 :where
 [?task "type" "task"]
 [?task "status" "offen"]
 [?task "projekt" ?projekt]]
;; ein Report: pro Projekt die Zahl offener Aufgaben

Before and after — Simple Query vs Datalog

CapabilitySimple QueryDatalog
Criteriaone propertyany number
Joining across blocksnoyes (join over variables)
Deriving / aggregatingnocount··sum··group
Reusableas a viewas a named rule
Learning curveminutessteeper, but more powerful

An honest question

How many of your reports do you rebuild every week because they connect several criteria no filter line can hold? The answer decides whether Datalog's steeper learning curve pays off for you — or whether a Simple Query already does the job.

Describe what counts — mium works out the rest.

One rule, and your second brain builds the report — and keeps it current while you think. No export, no clicking together; a companion that understands your criteria.

Reserve your slot··free →
SOP-ADVANCED-QUERY-DATALOG-1.0··Falktron GmbH, Oelde
The Spring School is over. See Day 93 → Play the game →