skipcheck

TM1 client · Docs · Reading and writing data

MemberSetService

from skipcheck_tm1.services import MemberSetService

Member sets: the results of MDX set expressions, as a single axis of tuples, kept on the server in /MemberSets and keyed by an ordinal TM1 assigns (1, 2, … in the session).

Like a cellset, a member set stays until it's deleted or the session ends. TM1 (11.8) lists none, though each reads by its ordinal: keep the ordinals execute returns, and delete what you're done with.

Evaluate a set expression and read its members' names, deleting the set after:

# The names of Region's leaves, with the member set deleted once they're read
with_names = ODataQuery.none().expand(CellsetAxis.TUPLES, lambda t: t.expand("Members", lambda m: m.select(Member.NAME)))
leaves = tm1.member_sets.execute("{TM1FILTERBYLEVEL({TM1SUBSETALL([Region].[Region])}, 0)}", with_names)
try:
    return [tuple.members[0].name for tuple in leaves.tuples]
finally:
    tm1.member_sets.delete(leaves.ordinal)

Keep a set on the server to read later, by the ordinal TM1 gives it:

# Keep a large set on the server and read it later by its ordinal; TM1 doesn't
# list member sets, so hold on to the ordinal, and delete the set when done
return tm1.member_sets.execute("{TM1SUBSETALL([Product].[Product])}").ordinal

The asyncio flavor, skipcheck_tm1.aio, has the same methods to await, on AsyncMemberSetService.

Members

executeEvaluates an MDX set expression, such as {TM1SUBSETALL([Region].[Region])}, keeping the result as a member set, with the Ordinal that keys it in MemberSets.
listGET MemberSets.
getThe set, or a Tm1NotFoundError if it's gone.
deleteFrees the set on the server.

execute

execute(mdx: str, query: ODataQuery | None = None, **options: Any) -> CellsetAxis

ExecuteMDXSetExpression: evaluates an MDX set expression, such as {TM1SUBSETALL([Region].[Region])}, keeping the result as a member set, with the Ordinal that keys it in MemberSets. Expand Tuples($expand=Members($select=Name)) to get its members in the same round trip. Needs schema 11.1.0.

TM1 REST ActionImport ExecuteMDXSetExpression

list

list(query: ODataQuery | None = None, **options: Any) -> list[CellsetAxis]

GET MemberSets. TM1 (11.8) lists none, though each reads by its ordinal with get.

TM1 REST EntitySet MemberSets

get

get(ordinal: int, query: ODataQuery | None = None, **options: Any) -> CellsetAxis

GET MemberSets(n): the set, or a Tm1NotFoundError if it's gone. Expand, for example, Tuples($expand=Members).

TM1 REST EntitySet MemberSets

delete

delete(ordinal: int) -> None

DELETE MemberSets(n): frees the set on the server.

TM1 REST EntitySet MemberSets