skipcheck

TM1 client · Docs · Queries

Filter

from skipcheck_tm1 import Filter

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

numeric_q = Filter.and_(Filter.starts_with(Element.NAME, "Q"), Element.TYPE.eq(ODataLiterals.enum_member("ibm.tm1.api.v1.ElementType", "Numeric")))
# (startswith(Name,'Q') and (Type eq ibm.tm1.api.v1.ElementType'Numeric'))
has_region = Filter.any("Hierarchies", "h", lambda 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

__init__ constructor
raw staticAn expression written by hand, used as is.
and_ staticAll of the given filters, at least one.
or_ staticAny of the given filters, at least one.
not_ staticnot filter.
starts_with staticstartswith(property,'prefix'), for a string property.
ends_with staticendswith(property,'suffix'), for a string property.
contains staticcontains(property,'text'), for a string property.
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 at least one value, each written as an OData literal.

__init__

constructor
__init__(expression: str, _raw: bool = False)

raw

static
raw(expression: str) -> Filter

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
and_(*filters: Filter) -> Filter

All of the given filters, at least one: joined with and, or the filter itself if there's only one.

or_

static
or_(*filters: Filter) -> Filter

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

not_

static
not_(filter: Filter) -> Filter

not filter.

starts_with

static
starts_with(prop: str | ODataProperty, prefix: str) -> Filter

startswith(property,'prefix'), for a string property.

ends_with

static
ends_with(prop: str | ODataProperty, suffix: str) -> Filter

endswith(property,'suffix'), for a string property.

contains

static
contains(prop: str | ODataProperty, text: str) -> Filter

contains(property,'text'), for a string property.

any

static
any(collection_path: str, variable: str, condition: Callable[[Variable], Filter]) -> Filter

collection/any(v:condition): true if any member of a collection matches. collection_path is used as is, such as Hierarchies; condition receives the range variable, from which to build paths (v.nav("Name")).

all

static
all(collection_path: str, variable: str, condition: Callable[[Variable], Filter]) -> Filter

collection/all(v:condition): true if every member of a collection matches. The arguments are as for any.

in_

static
in_(prop: str | ODataProperty, *values: Any) -> Filter

property in (a,b,c), with at least one value, each written as an OData literal. Not every TM1 version supports in; or_ of eq comparisons always works.