skipcheck

TM1 client · Docs · Queries

Filter

using Skipcheck.Tm1.Client.OData;

A $filter expression, built from ODataProperty comparisons and the canonical functions TM1 supports:

var numericQ = Filter.And(
    Filter.StartsWith(Element.Fields.Name, "Q"),
    Element.Fields.Type.Eq(ODataLiterals.EnumMember("ibm.tm1.api.v1.ElementType", "Numeric"))
);
// (startswith(Name,'Q') and (Type eq ibm.tm1.api.v1.ElementType'Numeric'))
var hasRegion = Filter.Any("Hierarchies", "h", h => h.Nav("Name").Eq("Region"));
// Hierarchies/any(h:h/Name eq 'Region')

Every binary expression is parenthesized, so precedence never depends on how a filter was composed. Values are written as OData literals (ODataLiterals.Of); the whole expression is percent-encoded once, when the query is rendered. Raw takes any expression as is, and is parenthesized when it's combined with others.

Note that TM1 compares names in $filter case- and space-sensitively, while keyed access ignores both. To find one object by name, use its key rather than a filter.

Members

Raw staticAn expression written by hand, used as is.
And staticAll of the given filters, joined with and; the filter itself if there's only one.
Or staticAny of the given filters, joined with or; the filter itself if there's only one.
Not staticnot filter.
StartsWith staticstartswith(property,'prefix').
EndsWith staticendswith(property,'suffix').
Contains staticcontains(property,'text').
Any staticTrue if any member of a collection matches.
All staticTrue if every member of a collection matches.
In staticproperty in (a,b,c), with each value written as an OData literal.
ToStringThe filter expression, before percent-encoding.
Equals
Equals
GetHashCode

Raw

static
Filter Raw(string expression)

An expression written by hand, used as is. Combined with others by And or Or, it's put in parentheses, so it keeps its meaning whatever operators it uses.

And

static
Filter And(params Filter[] filters)

All of the given filters, joined with and; the filter itself if there's only one.

Or

static
Filter Or(params Filter[] filters)

Any of the given filters, joined with or; the filter itself if there's only one.

Not

static
Filter Not(Filter filter)

not filter.

StartsWith

static
Filter StartsWith(ODataProperty property, string prefix)

startswith(property,'prefix').

EndsWith

static
Filter EndsWith(ODataProperty property, string suffix)

endswith(property,'suffix').

Contains

static
Filter Contains(ODataProperty property, string text)

contains(property,'text').

Any

static
Filter Any(string collectionPath, string variable, Func<Variable, Filter> condition)

collection/any(v:condition): true if any member of a collection matches.

Parameters

collectionPath
The path to the collection, such as Hierarchies, used as is.
variable
The range variable's name, an OData identifier.
condition
Builds the condition from the range variable (v.Nav("Name")).

All

static
Filter All(string collectionPath, string variable, Func<Variable, Filter> condition)

collection/all(v:condition): true if every member of a collection matches.

Parameters

collectionPath
The path to the collection, such as Hierarchies, used as is.
variable
The range variable's name, an OData identifier.
condition
Builds the condition from the range variable.

In

static
Filter In(ODataProperty property, params object?[] values)

property in (a,b,c), with each value written as an OData literal. Not every TM1 version supports in; Or of eqs always works.

ToString

string ToString()

The filter expression, before percent-encoding.

Equals

bool Equals(Filter? other)

Equals

bool Equals(object? obj)

GetHashCode

int GetHashCode()