Define a business unit as a value set
Some words your organisation uses are not sets of people but properties of a record: "the northern business unit" is the changes and incidents owned by its divisions, whoever opened them. A value set is the definition for that. It names the values a field must have, and the values it must not, and every answer that uses the word narrows its records to exactly those.
It is the definition to reach for when:
- a word is a business unit, a division or a product area that your records carry as a field, not a group of people in your directory;
- the set changes with re-organisations ("the northern unit, except the two divisions that moved to another leader"), and you want to change it in Prism, previewed and recorded, rather than in a source's SQL.
A word that names people is not a value set. Job titles and people belong in a classification: "everyone except titles containing Manager, Director or VP" is Who counts as a developer → Everyone, except people whose…, whose rules can match part of a title. A value set matches whole values only. Everyone who reports to a leader is a reporting line: see Set a default scope.
What a value set is
A value set is two lists of clauses. Each clause is a role and the values it takes:
- Include clauses: a record is in the set only if it has one of the listed values for every include clause.
- Exclude clauses: a record is out of the set if it has one of the listed values for any exclude clause.
For example, "the northern unit, except the Beta division":
| Side | Role | Values |
|---|---|---|
| include | division_parent | North |
| exclude | division | Beta |
Values are matched ignoring case and surrounding spaces: Beta, beta and
BETA are one value. Only spaces are ignored: a value that begins or ends
with a tab or a line break is refused when you save it. A source that spells a division one way this month and
another way the next is still matched.
A set may have only include clauses, only exclude clauses, or both. It holds at most 500 values per clause, each at most 200 characters.
A clause takes a role and its values, and nothing else. There is no
operator: a value set cannot match part of a value, such as a title that
contains a word. A clause with any other key, such as op, is refused when you
save it, and so is any key of the content other than include and exclude.
Records with no value
- An include clause never matches a record with no value for its field: a change with no division is in no business unit.
- An exclude clause keeps a record with no value for its field, because
that record is not one of the excluded values. The answer says how many it
kept in, for example "12 records have no
divisionand are kept in: 'the northern unit' leaves out only thedivisionvalues it lists".
Before you start: give the fields a role
A clause names a role, not a column, so that one value set reaches every
dataset that carries that kind of value, whatever each dataset calls its column.
A role is a name you choose (division, division_parent, business_unit),
declared on the field in your context stream's manifest:
fields:
- name: owning_division # YOURS
type: string
role: division # YOURS: what kind of value this field holds
- name: owning_division_parent # YOURS
type: string
role: division_parent # YOURS
On a second dataset of the same source that names the column differently, give that field the same role:
- name: preliminary_owning_division_name # YOURS
type: string
role: division
A role is for a string field, and a dataset has at most one field per role. Edit the manifest under Admin → Context streams, on the stream's manifest tab.
A clause must name a role that some context stream declares on a field
a value set can narrow by: a field that is not hidden and does not identify or
name a person. A value set that names any other role is refused when you save
it. The refusal names the roles that are declared, and says when the role is
carried only by hidden fields or person fields, or only by a context stream
that is switched off. Activating it asks again, from the row and from
Activate above the list alike, because a role can be taken off its field
after the save. Activation also refuses a key a value set does not read, on a
draft saved before Prism refused one. A value set already live when its role
goes is marked on its row in Your definitions: every question that uses it
is refused until a field carries the role again, or you revise the set. A live
value set that carries a key it does not read is marked too.
One role name is reserved and is not a value set's: copy_date marks a
snapshot's copy-date fields
(Copy a Postgres table or view).
Or give the role from the form
You do not have to edit the manifest by hand. The form has a Give a field a role section, which opens by itself while no field has a role yet:
- Choose the field, such as
divisions.division_name (divisions). The list holds the string fields of the context streams registered on this installation that copy rows into Prism's memory. A field that already has a role, that identifies or names a person, or that is hidden is not offered, and nor is a field of a stream that ships with Prism. - Type the role, such as
division, and press Give it the role.
Prism writes the role into that stream's stored manifest, exactly as a Save on
its Manifest tab would, so the manifest stays the record of it. A role that no
field of that stream carried yet, added and nothing else changed, keeps the
stream on with its verdicts, so the role is offered in the form at once.
Moving or removing a role, adding one the stream already carries on another
field, or adding one that an active value set already names, is a model change: each verdict returns to pending and, for a stream
read by connecting to something, it is switched off until approved and enabled
again. A value set's question over a role no field carried was refused, so
once a field carries the role it answers with a figure nobody has checked. A
hidden field cannot be given a role, and a field that carries a role cannot be
hidden: the form, registering a context stream and a Save on the Manifest tab
each refuse it. A hidden field that already carried its role keeps it. Give the parent column its own
role, such as division_parent, the same way.
For example, to define "the northern unit, less the Beta division" over a
stream whose divisions dataset has the columns parent_name and
division_name:
- Give
parent_namethe roledivision_parent, anddivision_namethe roledivision. - Give the matching column of your changes and incidents datasets, such as
owning_division, the roledivisionas well. - Make the value set below: include
division_parentNorth, excludedivisionBeta.
Make one on the Definitions page
As a super admin, open Admin → Definitions and press Start on What a business unit is.
-
Type the word readers will use, any other words for it (comma separated), and a one-line summary.
-
Under Records that count, choose a field. Prism then lists the values that role holds, most common first. Type to search past the top of the list. Tick the values that make up the set. Each one you tick appears as a chip above the list; its × removes it. A role that a hidden field carries is refused when chosen: unhide the field on its stream, or take the role off it.
-
Values that differ only in case or surrounding spaces are offered as one choice. The choice says how many spellings it covers, such as "3 spellings", and hovering over it lists them. Ticking it matches every one of those spellings.
-
Press Add a field to require a second role as well. Under Records left out, add the fields and values that take records out of the set, in the same way.
-
Press Save draft, then Preview. Activate it from its ⋯ menu in Your definitions, as for every definition, or select several and use Activate above the list. A value set selects no people, so its preview has no headcount. Instead it says, for each field, which datasets its role reaches and, on each, how many rows the chosen values match and how many of the values occur there, naming any that do not. Rows are every row Prism holds for the dataset, older copies of a snapshot included, so they say how common the values are. A dataset is listed but not counted, with the reason, when:
- nothing has been copied from it yet;
- its column is not in Prism's memory yet;
- its field cannot be read here;
- its rows are read from its own system;
- the field is hidden, or identifies or names a person;
- the dataset's SQL tries to write (the preview only reads);
- the dataset's SQL fails for any other reason: the reason reads "it could not be read" and names the error;
- counting it takes longer than 5 seconds.
The whole preview stops counting after 20 seconds.
Activate above the list counts each value set nobody has previewed before it activates it, and stops starting those counts 30 seconds into the request. A value set it did not reach is listed as not attempted: activate it again, or preview it from its row first.
To change one after a re-organisation, open its ⋯ menu in Your definitions and choose Edit. The form opens with its clauses filled in, and saving writes the next revision; make that live when it is right. If Prism refuses a save, the reason is shown under the form.
A field that no context stream has copied any rows for yet has no values to offer, and the list says so under the field.
Create and activate one with the API
A value set is a definition like any other: you write a draft, preview it and make it live, and every revision is kept. Scripted, as a super admin:
curl -sS -X POST "https://<host>/api/admin/definitions" \
-H 'content-type: application/json' --cookie "<your session>" \
-d '{"name": "northern unit", "kind": "value_set",
"summary": "the northern business unit, less the Beta division",
"aliases": ["north"], "binding": {}, "base_revision": 0,
"content": {"include": [{"role": "division_parent", "values": ["North"]}],
"exclude": [{"role": "division", "values": ["Beta"]}]}}'
Then preview and activate that revision with
POST /api/admin/definitions/preview and
POST /api/admin/definitions/activate, each with {"name": ..., "revision": ...}.
A value set selects no people, so its preview has no headcount: its
preview.clauses lists what each clause reaches, as on the page. Prism counts
it; a preview request that sends counts for a value set is refused.
After a re-organisation, write the next revision with the changed lists
(base_revision set to the one you are replacing), preview it and activate it.
Answers use the new lists from then on, and say which revision they used.
Verification questions that use the value set go back to pending whenever
it is activated, a new revision of it is activated, or it is withdrawn. That
applies to every context stream whose stored questions name the value set, by
its name or an alias. Their figures now come from a different revision, or the
question is refused, so a verdict on the old figure no longer says anything
about the new one. The other questions keep their verdicts, and the stream
stays on. A verdict on a figure computed before the value set changed is
refused: run the question again, then judge it. The same holds for a
definition that selects people, when a stored question counts it by name
(population: {"named": …}) or narrows to it (narrowed_to).
The store refuses a value set with no clause, a role named twice on one side, a blank value, two values that are the same once case and spaces are ignored, a key it does not read, and a role no context stream declares.
What a question gets
When a question uses the word, the agent passes the value set to the query rather than writing its own filters. The answer:
- applies every clause to the queried dataset's field of that role;
- names the value set and its revision, with each clause and the field it
reached (the
whereblock of the answer); - says how the values were matched;
- says how many records an exclude kept in for want of a value.
A dataset with no field of a clause's role is refused, naming the datasets of the source that have one, so the agent can ask the right one. A people word passed as a value set is refused too: it belongs in the question's population.
Restricted viewers
A value set only ever narrows what a question counts. For a viewer restricted to their reporting line, the records are narrowed by the value set and by their line, never widened by either. Viewers see a value set's name, summary and clauses: they are your definition, not anyone's data.