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
execute | 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. |
list | GET MemberSets. |
get | The set, or a Tm1NotFoundError if it's gone. |
delete | Frees the set on the server. |
execute
execute(mdx: str, query: ODataQuery | None = None, **options: Any) -> CellsetAxisExecuteMDXSetExpression: 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) -> CellsetAxisGET 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) -> NoneDELETE MemberSets(n): frees the set on the server.
TM1 REST EntitySet MemberSets