This page covers the everyday OData query options: choosing columns, filtering, sorting and limiting rows. It also explains how values are written and how the results become dataset columns.
Anatomy of a dataset query
- Start with the object name, such as Tags. Capitals in object and field names don't matter.
- Add ?, then query options separated by &.
- Each system query option starts with $.
- Write everything on one line. The examples in this help sometimes wrap for readability. Join them back into one line in the Query Editor.
Query options
| Option | Purpose | Example |
|---|---|---|
| $select | Choose columns | $select=Name,Description |
| $filter | Keep only matching rows | $filter=startswith(Name,'WELL-A') |
| $orderby | Sort, ascending by default | $orderby=Name desc |
| $top | Return at most n rows (up to 1,000) | $top=100 |
| $skip | Skip the first n rows | $skip=100 |
| $count=true | Ask for the total row count. In a dataset, use aggregation to count instead. | |
| $apply | Group and aggregate on the server | See Aggregation |
| $compute | Add a calculated column | $compute=year(CreatedDate) as Yr |
| $expand | Include related objects. Not for datasets, see Getting related values into a dataset. |
The $ is optional: filter=Name eq 'X' works like $filter=Name eq 'X'. $search isn't supported.
To read one record of a database-backed object, put its Id in brackets, such as Workbooks(12) or SentinelEvents(884213). A record that doesn't exist, or that you can't see, returns 404.
Always use $select in datasets. It keeps the dataset to the columns you need, makes queries faster, and protects your page if new fields are added to an object in a later release.
Filtering
Comparison and logic
| Operator | Meaning | Example |
|---|---|---|
| eq, ne | Equal, not equal | Name eq 'WELL-A12' |
| gt, ge, lt, le | Greater than, greater or equal, less than, less or equal | StartTime ge 2026-09-01T00:00:00Z |
| and, or, not | Logic. Use brackets to group. | IsCurrent eq true and (SeverityName eq 'High' or SeverityName eq 'Critical') |
| in | Matches one of a list | Name in ('WELL-A12','WELL-A14') |
| eq null, ne null | Missing, or not missing | EndTime eq null |
Text functions
| Function | Example |
|---|---|
| contains, startswith, endswith | contains(Description,'Gas Lift') |
| tolower, toupper | toupper(Name) eq 'SEP-01' |
| indexof, substring, length | indexof(NativeName,'flow') gt -1 (counts from 0) |
| concat, trim | concat(Name,' (old)') |
Date functions
| Function | Example |
|---|---|
| year, month, day, hour, minute | year(CreatedDate) eq 2026 |
| date | date(StartTime) eq 2026-09-15 |
| now() | StartTime ge now() sub duration'P7D' on live objects such as SapiCases. Date arithmetic like this fails on database-backed objects, so use the OI query functions there, such as StartTime ge OI.daysago(7). |
Conditions on collections
any and all test the related rows of a collection:
SapiTimeWindows?$filter=Entities/any(e: e/Name eq 'K-201')&$select=Id,StartTime,EndTime
Time windows that cover compressor K-201.
Templates/any() with no condition means "has at least one".
Writing values
| Type | How to write it | Example |
|---|---|---|
| Text | Single quotes. Double a single quote to include one. | 'Operator''s Note' |
| Date and time | ISO 8601 in UTC, ending in Z, with no quotes | 2026-09-01T00:00:00Z |
| Date only | yyyy-mm-dd, no quotes | 2026-09-01 |
| Duration | duration'...' in ISO 8601 | duration'PT12H' |
| Number | As is | 42, 1450.5 |
| Boolean | true or false | IsCurrent eq true |
| Null | null | EndTime eq null |
| Enumeration | Full type name, then the value in quotes. The value in quotes on its own also works. | State eq P2.Server.DataDictionary.EntryState'Submitted' or State eq 'Submitted' |
Enumeration values
| Field | Enumeration type | Values |
|---|---|---|
| Tags.Type, Calculations.Type | P2.Server.DataDictionary.DataObjectSourceType | None, Datasource, Calculation, Analysis, MergedDataset, TimeSeriesDataset |
| Attributes.DataType | P2.Server.DataDictionary.AttributeDefinitionDataType | None, TimeSeries, Matrix |
| AttributeValueInstances.DataType | P2.Server.DataDictionary.AttributeValueDataType | None, NotApplicable, Boolean, DateTime, Decimal, Duration, Integer, String, Tag, Dataset, ... |
| SapiCases.State, SapiIssues.State, SapiSummaries.State | P2.Server.DataDictionary.EntryState | None, Draft, Pending, Submitted |
Times are UTC. OI OData stores and compares times in UTC. Write Z on every timestamp. Dataset columns come back in UTC, and Explorer displays them in the page's time zone as usual.
Related objects
Use / to reach a field on a related object, in $filter, $orderby, $compute and $apply:
Workbooks?$filter=Workspace/Name eq 'Production Ops'&$select=Name,LastModified&$orderby=Name
EntityRelationships?$filter=Hierarchy/Name eq 'Production Hierarchy' and Parent/Name eq 'ALPHA'&$compute=Child/Name as Well&$select=Well
In a browser, Excel or Power BI you can also use $expand to return the related object itself, nested inside each row:
Workbooks?$select=Name&$expand=Workspace($select=Name)
A dataset is a flat table, so the OI OData Adaptor can't use nested results. A query that returns a nested object or a collection, such as one with $expand, fails in a dataset with the message "The following OData data type is not supported".
To bring a related value into a dataset, give it its own column with $compute, then select it:
Workbooks?$compute=Workspace/Name as WorkspaceName&$select=Name,WorkspaceName,LastModified
The same applies to grouping. Grouping directly on Workspace/Name returns a nested object. Compute an alias first, then group on the alias:
Workbooks?$apply=compute(Workspace/Name as WorkspaceName)/groupby((WorkspaceName),aggregate($count as Workbooks))
For lists of related rows, such as every asset a time window covers, query the related object directly instead. For example, query EntityRelationships filtered by parent rather than expanding an asset's children.
How results become columns
Each property in the result becomes one dataset column, named exactly as the property is named, or as its as alias.
| OData type | Dataset column type |
|---|---|
| Text (Edm.String), GUID | String |
| Whole number (Edm.Int16, Edm.Int32, Edm.Byte) | Integer |
| Large whole number (Edm.Int64) | Decimal |
| Decimal, double (Edm.Decimal, Edm.Double) | Decimal |
| Single (Edm.Single) | Single |
| Boolean | Boolean |
| Date and time (Edm.DateTimeOffset) | Date/time, in UTC |
| Duration | Duration |
Things to know
- A column's type is set by its first non-null value. If the first rows are null, Explorer waits for the first value to decide.
- A column that is null in every row has no type. This is usually harmless, but if a chart needs a number, make sure the query returns at least one value.
- Dynamic entry fields keep their type. A Decimal form field on SapiCases, SapiIssues, SapiSummaries and SapiTimeWindows comes back as a number, a Boolean field as true or false, and a field that holds several values as text. See Entries.
- Union output is text. Every column from Union is a string.
- A dataset returns at most 1,000 rows. See Limits and Performance.
Special characters
The adaptor sends your query text as it is. Most characters are fine, including spaces and quotes. Some characters have a special meaning in a URL, so inside a text value you type in the query you must encode them. Values that come from a parameter with ODataParam are encoded for you.
| Character | Write it as | Example |
|---|---|---|
| & | %26 | Name eq 'Oil %26 Gas' |
| # | %23 | contains(Name,'%23') |
| + | %2B | contains(Name,'C%2B') |
| % | %25 | contains(Description,'50%25') |
