Skip to content

Commit

Permalink
add mdx dimension hierarchize
Browse files Browse the repository at this point in the history
  • Loading branch information
vishn90 authored and MariusWirtz committed Aug 7, 2023
1 parent fd5e5fb commit f2d22db
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mdxpy/mdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def ancestor(member: Union[str, Member], ancestor: int) -> 'MdxHierarchySet':
return AncestorHierarchySet(member, ancestor)

@staticmethod
def drill_down_level(member: Union[str, Member], level) -> 'MdxHierarchySet':
def drill_down_level(member: Union[str, Member], level: int) -> 'MdxHierarchySet':
if isinstance(member, str):
member = Member.of(member)
return DrillDownLevelHierarchySet(member, level)
Expand Down Expand Up @@ -705,6 +705,11 @@ def __init__(self, member: Member, level):
self.level = level
self.member = member

if level:
self.level = level
else:
self.level = 1

def to_mdx(self) -> str:
startstring = ''
endstring = ''
Expand Down
7 changes: 7 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ def test_mdx_hierarchy_set_drill_down_level(self):
"{DRILLDOWNLEVEL({[dimension].[dimension].[element]})}",
hierarchy_set.to_mdx())

hierarchy_set = MdxHierarchySet.drill_down_level(Member.of("Dimension", "Element"), level=3)

self.assertEqual(
"{DRILLDOWNLEVEL(DRILLDOWNLEVEL(DRILLDOWNLEVEL({[dimension].[dimension].[element]})))}",
hierarchy_set.to_mdx())


def test_mdx_hierarchy_set_tm1_drill_down_member_all_recursive(self):
hierarchy_set = MdxHierarchySet.members([Member.of("dimension", "element")]).tm1_drill_down_member(
recursive=True)
Expand Down

0 comments on commit f2d22db

Please sign in to comment.