in

(T.‘a in U.‘a) -> T.boolean, operator

The reserved keyword in is a binary operator returning true if the value found on the left vector exists anywhere in the right vector, and false otherwise.

Example:

table Products[product] = with
  [| as product, as Price |]
  [| "apple",  1.25 |]
  [| "banana", 0.75 |]
 
table Orders = with
  [| as Pid, as OrderDate, as Quantity |]
  [| "apple",  date(2020, 8, 15), 3 |]
  [| "apple",  date(2020, 8, 16), 7 |]
  [| "orange", date(2020, 8, 16), 2 |]
 
where Orders.Pid in product // 'orange' is filtered out
  Orders.Amount = Orders.Quantity * Products.Price[Orders.Pid]
  show table "Orders" with
    Orders.Pid
    Orders.OrderDate
    Orders.Amount

The in keyword can also be applied to tuples of vectors.

table T = with
  [| as A, as X, as Y, as Z |]
  [| "foo", 0, 1, 1 |]
  [| "bar", 1, 0, 0 |]

table U = with
  [| as X, as Y, as Z |]
  [| 0, 0, 0 |]
  [| 0, 1, 1 |]

where (T.X, T.Y, T.Z) in (U.X, U.Y, U.Z) // select the 'foo' line 
  show table "T" with T.A, T.X, T.Y, T.Z

The in operator also works with enum values, using the enum type itself rather than the text labels.

table enum ME = "A", "B", "C"

table A = extend.range(2)
A.Code = if A.N == 1 then "A" else "B"
A.E = enum<<ME>>(A.Code)

table B = extend.range(3)
B.Code = match B.N with
  1 -> "A"
  2 -> "C"
  .. -> "B"
B.E = enum<<ME>>(B.Code)

where B.E in A.E // filters out "C"
  show table "Common enums" with
    B.Code
    B.E

(tile placement in region) ᐅ tile, keyword

The keyword in is also used in tile placement to target a grid by name, as in ... in regionName. This syntax is part of the StyleCode placement block and is commonly used with show region containers. See region for the full reference.

overview = show region { ..4, ..6 nocard }

show label "Headline" { .., ..2 in overview }
show table "Summary" { .., 4..5 in overview } with
  "A" as "Item"
  42 as "Value"
User Contributed Notes
0 notes + add a note