Spreadsheet report syntax

Spreadsheet report syntax

Relatics allows users to create reports to share their project data. This allows others to view your data in cases where they do not have access to Relatics or would rather view the data in a spreadsheet. Additionally, generating a report can provide a snapshot of current project data.

The spreadsheet reports feature is accessed by clicking relatics-icon-report Reports from Data output on the workspace menu.

Relatics syntax

A report originates from a template. The template determines which data will be printed in the report and how it will be visualized. This article will focus on the syntax used to make a spreadsheet report template. Before we dive into examples of syntax constructions, please note that a template has to be built in an .xlsx file format. In the spreadsheet, you can use Relatics syntax and other functionalities simultaneously. This gives you access to formation, calculation, pivot table, and similar functions in the spreadsheet, and, in turn, creative control over the presentation of your data.

Iterator

.xlsx template

Action
Id Name
[Action]
{@Id} {Name}
[.Action]

Published report

Action
Id Name
ACT-1 Cleaning the windows
ACT-2 Sweeping the floor
ACT-3 Painting the wall

In the example above, [Action] is an iterator. By using an iterator in a template, Relatics is instructed to ‘iterate’ through all elements of the specified type element (e.g. Action). In other words, Relatics will go through every element in the type element Action. Between the iterator tags, Relatics is instructed to parse syntax for every iteration of the specified type (e.g. Action). In the example, this means that for every Action, the ID and Name are printed.

Notes:

  • An iterator can be recognized by brackets and the name of a type within the brackets. For example, [Action].
  • An iterator must always be closed by brackets with a dot. For example, [.Action]. Optionally, an iterator can be closed without repeating the type name, like so [.].
  • While processing a template, Relatics can distinguish between parsable syntax and other text to be printed in the report.
  • Please note that the styling of an iterator should be consistent, or you might encounter syntax errors.

Inserter

.xlsx template

Actions
[Action]
{@Id} – {Name}
[.Action]

Published report

Actions
ACT-1 – Cleaning the windows
ACT-2 – Sweeping the floor
ACT-3 – Painting the wall

In the template examples given earlier, you may have noticed model references between curly braces (e.g., {Name}). These so-called inserters define which Relatics properties will be printed in the report output.

Notes:

  • What is between curly braces must equate to one value per iteration.
  • A single iterator can have multiple inserters.
  • Please note that the styling of an inserter should be consistent, or you might encounter syntax errors.

Next to properties, system attributes can be used for inserters. System attributes are not defined by a power user but, instead, are predefined by Relatics. Inserters with system attributes can be recognized by the @ symbol. Notice how, in the example given earlier, the inserter {@Id} was responsible for printing the IDs of the Iterator Action.

System attribute Description
{@Id}
This system attribute prints the value in the corresponding element ID column (e.g., ACT-1).
{@DisplayName} This system attribute prints the value of the display name of an element part of a collection relation.
{@Deeplink} This system attribute prints the URL that directly leads to the element’s detail page.
{@User} This system attribute prints the first and last name of the user generating the report.
{@Workspace} This system attribute prints the workspace name from which the report is generated.
{@ProjectDateTime} This system attribute prints the date and time of the project as of generating the report.

Nesting

.xlsx template

Person is responsible for: Action
Name Output
[Person]
{Name} {is responsible for: Action/Name}
[.Person]

Published report

Person is responsible for: Action
Name Output
John Cleaning the windows
Jane Sweeping the floor
Mary Painting the wall

An iterator is an instruction for Relatics to reach specific type elements. It gives navigational instructions to the reports engine, similar to how you click on an element Relatics table to navigate its relations and properties. It is possible to print the Actions by a responsible Person in the report output. We can achieve this in the reports syntax by nesting our iterators, like in the example above. With the iterator [Person], an iteration is started through all elements of the Person type element. Nested in is a single inserter. Similarly to a URL, you separate the model references within the inserter with a forward slash.

Note:

  • In the case of a relation with a multi-cardinality, it can be used just once within the same iterator.

Separator

.xlsx template

Person has unfinished: Actions
Name Output
[Person]
{Name} {has unfinished: Action/Name};
[.Person]

Published report

Person has unfinished: Actions
Name Output
John Cleaning the windows;Sweeping the floor;Painting the wall;

Consider the template script above. Notice that the semicolon at the end of the output is undesirable if you want to deliver a concise report. After all, we just want to summarize every Action and stop once the last Action has been printed. The extra semicolon is printed because in the script we instruct Relatics to print the Name property for every Action, but also to print a semicolon for every Action.

To prevent situations like this, an optional operator [|] can be used, called the separator. The separator can exclusively be used within an iterator. The fragment of the iterator behind the Separator is repeated for every iteration except the last one.

.xlsx template

Person has unfinished: Actions
Name Output
[Person]
{Name} {has unfinished: Action/Name}[|];
[.Person]

Published report

Person has unfinished: Actions
Name Output
John Cleaning the windows;Sweeping the floor;Painting the wall

Filter

It is possible to apply filters to the iterators in your template. Filters are specified within iterator brackets, and it is possible to apply multiple filters on a single iterator. The following example will elaborate on the syntax used to apply a filter in a Report:

.xlsx template

Action
Name Status
[Action | FILTER({Status} = “New”)]
{Name} {Status}
[.Action]

Published report

Action
Name Status
Sweeping the floor New

To apply a filter to an iterator, start by putting a pipe symbol after the type element name. Then type FILTER and write your filter operation between parentheses. In this case, Status is an option property of the Action type element, and we used it to filter for Relatics elements with a Status property of ‘New’.

It is only possible to filter by certain property types:

Property type .xlsx template Published report
Option One filter value:

Action
Name Status
[Action | FILTER({Status} = “New”)]
{Name} {Status}
[.Action]

Multiple filter values:

Action
Name Status
[Action | FILTER({Status} IN (“New”, “Busy”))]
{Name} {Status}
[.Action]
One filter value:

Action
Name Status
Sweeping the floor New

Multiple filter values:

Action
Name Status
Cleaning the windows Busy
Sweeping the floor New
Date
Action
Name Deadline
[Action | FILTER({Deadline} > “1950-01-01”) FILTER({Deadline} < “2050-01-01”)]
{Name} {Deadline}
[.Action]
Action
Name Deadline
Cleaning the windows 2002-01-02
Sweeping the floor 2002-01-03
Painting the wall 2002-01-01
Number
Action has responsible: Person
Name Output
[Action | FILTER({has responsible: Person/Age} NOTEMPTY) FILTER({has responsible: Person/Age} >= 18)]
{Name} {has responsible: Person/Age}
[.Action]
Action has responsible: Person
Name Output
Cleaning the windows 31
Sweeping the floor 33
Painting the wall 32

Filters can also be applied to iterators containing Relations without specified properties. However, you are only able to filter whether a relation ‘exists’ or does ‘not exist’:

.xlsx template

Action
Name
[Action | FILTER([has responsible: Person] EXISTS)]
{Name}
[.]

Published report

Action
Name
Cleaning the windows
Sweeping the floor
Painting the wall

Notes:

  • It is not possible to filter by specific instances.
  • It is possible to apply multiple filters within a single iterator, e.g. [Action | FILTER({has responsible: Person/Age} NOTEMPTY) FILTER({has responsible: Person/Age} >= 18)]
  • When a filter on a nested iterator should also affect the parent iterator, the filter needs to be repeated on its parent.
  • A filter’s styling (e.g., different fonts, font sizes, and colors) cannot differ from that of its iterator; differences may lead to syntax errors.
  • A filter on date and option properties will need the value between quotes, but a filter of a number property will not need the value between quotes.
  • The report can only parse dates in the yyyy-mm-dd format; dates in other formats may lead to syntax errors.
  • The script syntax for ‘not exist’ is NOTEXISTS.
  • You can filter by collection relations. To illustrate, take our example above and imagine an Action can have a Person or an Organization responsible for it. You can choose whether to filter:
    1. By Person exclusively. E.g. [Action | FILTER([has responsible: Person] EXISTS)]
    2. By Organization exclusively. E.g. [Action | FILTER([has responsible: Organization] EXISTS)]
    3. By Person or Organization. E.g. [Action | FILTER([has responsible: *] EXISTS)]

Archived elements

By default, iterators loop through all the elements of a type element. This is also true for type elements where archiving is configured. In case you only want to iterate through a specific archiving state, some extra syntax has to be added to the iterator:

Archived state .xlsx template Published report
Live only
Action
Name Status
[Action | ARCHIVEEXCLUDED]
{Name} {Status}
[.Action]
Action
Name Status
Cleaning the windows Busy
Sweeping the floor New
Archived only
Action
Name Status
[Action | ARCHIVEONLY]
{Name} {Status}
[.Action]
Action
Name Status
Painting the wall Done

Sort

Report syntax allows for the inclusion of sorting, similar to the sorting system of a column in a Relatics table. By default, iterators are sorted according to the sorting a power user has published on the all elements view of the corresponding type element.

Now consider:

.xlsx template

Action has responsible: Person
Name Id Output
[Action | SORT({has responsible:Person/Name})]
{Name} {Name} {has responsible:Person/Name}
[.Action]

Published report

Action has responsible: Person
Id Name Output
ACT-2 Sweeping the floor Jane
ACT-1 Cleaning the windows John
ACT-3 Painting the wall Mary

To apply sorting to an iterator, start by putting a pipe symbol after the type element name. Then type SORT and write your sorting operation between parentheses. In the example, sorting is applied to a relation of the Action iterator. By disclosing a path to the Name property of a responsible Person, we have instructed the iterator to sort alphabetically by their names.

Optionally, we can tell Relatics to sort an iterator in reverse order by using DESC or force regular order by using ASC:

.xlsx template

Action has responsible: Person
Name Id Output
[Action | SORT({has responsible:Person/Name} DESC)]
{Name} {Name} {has responsible:Person/Name}
[.Action]

Published report

Action has responsible: Person
Id Name Output
ACT-2 Painting the wall Mary
ACT-1 Cleaning the windows John
ACT-3 Sweeping the floor Jane

Notes:

  • It is possible to apply multiple sorts within a single iterator.
  • Properties of the data type option with custom order enabled are not sorted alphabetically; rather, they are sorted by the order of option items in a property.
  • Making the styling of a sort different from that of its iterator is not supported and may lead to syntax errors.
  • Type elements with positioning enabled will be sorted by their position in the workspace.

Skip if not exists & skip if empty

There are scenarios when it is impractical to print certain elements or properties, for instance, when they do not contain data. These cases can be solved by adding a skip if not exists prefix and postfix around an iterator or a skip if empty prefix and postfix around an inserter. Let’s look at a case where you are reporting on Actions assigned to a responsible Person:

.xlsx template

Person is responsible for: Action
Name Output
[Person]
{Name} [?][is responsible for: Action] Actions: – {Name}
[.]Thanks for your service, {Name}![.?]
[.]

Published report

Person is responsible for: Action
Name Output
Jane Actions:
– Sweeping the floorThank you for your service!
John Actions:
– Cleaning the windowsThank you for your service!
Mary Actions:
– Painting the wallThank you for your service!
Tom

Since Tom has no actions, we decided not to print Actions or a thank-you message. We used the prefix [?] to instruct Relatics to skip text if no existing iterator exists. Then, we used the postfix [.?] to instruct where it stops skipping text. With this skip if not exists construction, we avoided printing unwanted text for Tom.

Notes:

  • The skip if empty prefix and postfix can be placed around an inserter to skip text around property values that are empty. Instead of brackets, you use accolades like so: [Person]{?}Name:{Name}{.?}[.]
  • These constructions don’t work across multiple cells.