Combining Data

OI OData provides two ways to combine data from multiple objects: Union and $crossjoin.

This article applies to version 26R2 and later of IFS OI Explorer.

Sometimes one object isn't enough. "What changed in the configuration this week?" spans tags, datasets, templates and workbooks. "Tags with their datasource's adaptor" needs two objects side by side. OI OData has two tools for this:

Tool Like SQL's Use it to
Union UNION ALL Stack rows from several objects into one list
$crossjoin JOIN Put columns from two or more objects side by side

Both work only on database-backed objects.

Union

Union stacks rows from several branches into one table. Each branch is an object with its own filter, and can add calculated columns so every branch supplies the same output columns.

Union?branches=<Object>($filter=...;$apply=...),<Object>($filter=...)&select=<col>,<col>[&orderby=...][&apply=...][&top=...][&skip=...]

Note: For Union, do not use $ with the outer options. Use $ only for options inside each branch, and separate those options with ;.

Option Required Meaning
branches Yes A comma-separated list of Object($filter=...). A branch can add ;$apply=compute(...), ;$apply=groupby(...) or ;$apply=compute(...)/groupby((...),aggregate($count as ...)). A branch $apply can't use filter(), and $count is its only aggregate.
select Yes The output columns. Every branch must supply each one, as a real column or a compute alias.
orderby No Sort on output columns. Numbers and dates sort correctly.
apply No Group the combined rows. Must be a groupby with at least one column. Supports $count, countdistinct, min, max and OI.stringagg.
top No Row limit
skip No Rows to skip before top applies

Every Union output column is text, including numbers and dates. Booleans are true or false.

Examples

Recent configuration changes. Tags, datasets and templates changed in the last 7 days, in one list:

Union?branches=TagDefinitions($filter=LastModified ge OI.daysago(7);$apply=compute('Tag' as Item)),Datasets($filter=LastModified ge OI.daysago(7);$apply=compute('Dataset' as Item)),TemplateDefinitions($filter=LastModified ge OI.daysago(7);$apply=compute('Template' as Item))&select=Item,Name,LastModified&orderby=LastModified desc

Item Name LastModified
Template Gas Lift Well 2026-10-06T09:12:44Z
Tag A12_THP 2026-10-05T23:01:10Z
Dataset Daily Allocated Oil by Well 2026-10-03T04:30:00Z

The same changes, counted per object type. Add an outer apply:

...&select=Item,Name,LastModified&apply=groupby((Item),aggregate($count as Changes,LastModified with max as Latest))&orderby=Changes desc

Workbooks and pages changed, with their workspace:

Union?branches=Workbooks($filter=LastModified ge ODataParam(since,datetime) and Workspace/Name ne null;$apply=compute('Workbook' as Item,Workspace/Name as Workspace)),Pages($filter=LastModified ge ODataParam(since,datetime) and Workspace/Name ne null;$apply=compute('Page or trend' as Item,Workspace/Name as Workspace))&select=Item,Workspace,Name,LastModified&orderby=LastModified desc

Explorer activity by hour of day, split into page views and trend views:

Union?branches=AnalyticsEvents($filter=Timestamp ge OI.daysago(30) and startswith(Name,'Open Page');$apply=compute('Page views' as EventType,hour(Timestamp) as HourOfDay)/groupby((EventType,HourOfDay),aggregate($count as EventCount))),AnalyticsEvents($filter=Timestamp ge OI.daysago(30) and startswith(Name,'Open Trend');$apply=compute('Trend views' as EventType,hour(Timestamp) as HourOfDay)/groupby((EventType,HourOfDay),aggregate($count as EventCount)))&select=EventType,HourOfDay,EventCount&orderby=EventType asc,HourOfDay asc

What a branch filter supports

  • eq, ne, gt, ge, lt, le, and, or, not, in (a list of literals), and null checks
  • contains, startswith, endswith, tolower, toupper, length, concat
  • now(), date(), year(), month(), day(), hour(), minute(), second()
  • Every OI query function except OI.normalizesql
  • One level of navigation, such as Workspace/Name
  • any() over related rows that aren't access-controlled
  • ODataParam keywords

Other functions, such as indexof, are rejected with 501 Not Implemented and a clear message, as is arithmetic (add, sub). Use OI.daysago(7) rather than now() sub duration'P7D'.

Navigation and security. If you can't see a related object, its value comes back null. For example, Workspace/Name is null for another user's private workspace. Add Workspace/Name ne null to leave those rows out.

Paging Union

A Union or $crossjoin returns at most 5,000 rows per request. A result with more rows is rejected with an error, not cut short. Narrow it, or page through it with $skip and $top: $skip=0&$top=1000, then $skip=1000&$top=1000, and so on. Each row appears on exactly one page, with or without orderby. In a dataset, it's usually better to aggregate with apply so the result stays small.


$crossjoin

$crossjoin is the standard OData join. Every row of the first object is paired with every row of the second, and $filter keeps the pairs that match. Prefix every column with its object name.

$crossjoin(ObjectA,ObjectB[,ObjectC])?$select=ObjectA/Col,ObjectB/Col&$filter=<join condition> and ...&$orderby=...&$top=...
  • Join 2 or 3 objects, each only once.
  • $select is required. Output columns are named Object_Column, such as TagDefinitions_Name.
  • $filter is required, and must join every object to the others with eq between their columns, combined with and. Each side of the eq may be a column or a function of columns from one object, such as year(ObjectA/Created) eq year(ObjectB/Created). A join that is missing, or only inside an or, is rejected: it would pair every row of A with every row of B.
  • Join on the related object's key through its navigation, such as TagDefinitions/Datasource/Name eq Datasources/Name. A path can go one navigation past the object name.
  • Each output column keeps its type: numbers, dates and booleans come back as numbers, dates and booleans.
  • Security is applied to each object.

Tags with their datasource's adaptor:

$crossjoin(TagDefinitions,Datasources)?$select=TagDefinitions/Name,Datasources/Name,Datasources/AdaptorName&$filter=TagDefinitions/Datasource/Name eq Datasources/Name and startswith(TagDefinitions/Name,'A12_')&$orderby=TagDefinitions/Name

Each workbook publish, newest first:

$crossjoin(Workbooks,WorkbookPublishHistory)?$select=Workbooks/Name,WorkbookPublishHistory/UserDisplayName,WorkbookPublishHistory/Timestamp&$filter=Workbooks/Id eq WorkbookPublishHistory/Workbook/Id&$orderby=WorkbookPublishHistory/Timestamp desc&$top=100


Allowed objects

Union branches and $crossjoin accept these database-backed objects:

Area Objects
Asset model Entities, EntityRelationships, TemplateDefinitions, TemplateInstances
Data sources Datasources, Datasets, TagDefinitions
Entries and forms EntryRecords, Forms, NamedLists, EntryAuditLogs, FormFields, EntryForms, FormSchemas
Sentinel SentinelEvents
Explorer content Workbooks, WorkbookPublishHistory, Pages
Usage and security AnalyticsEvents, UserGroupRoles, UserGroupUsers, UserRoles

Live objects such as Tags and SapiCases, and LogSheetRows, can't be used. Use their database-backed equivalents.

A branch on Entities can use the asset's own columns and its TemplateInstances, ChildRelationships and Metadata, but not Templates or PrimaryTemplate.


Next: OI Query Functions

Related: Aggregation and Calculated Columns · Limits and Performance

 

Comments are closed