How to use the mdxpy.MdxBuilder function in mdxpy

To help you get started, we’ve selected a few mdxpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cubewise-code / tm1py / Tests / Cell.py View on Github external
cells = {
            ('e1', 'e1'): 1,
            ('e1', 'e2'): 2,
            ('e1', 'e3'): 3,
        }
        self.tm1.cubes.cells.write_values(CUBE_RPS1_NAME, cells)

        self.tm1.cubes.cells.relative_proportional_spread(
            value=12,
            cube=CUBE_RPS1_NAME,
            unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[e2]", "[" + DIMENSION_RPS2_NAME + "].[c1]"),
            reference_cube=CUBE_RPS1_NAME,
            reference_unique_element_names=("[" + DIMENSION_RPS1_NAME + "].[c1]", "[" + DIMENSION_RPS2_NAME + "].[c1]"))

        mdx = MdxBuilder.from_cube(CUBE_RPS1_NAME) \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_RPS1_NAME, "e2"))) \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
            Member.of(DIMENSION_RPS2_NAME, "e1"),
            Member.of(DIMENSION_RPS2_NAME, "e2"),
            Member.of(DIMENSION_RPS2_NAME, "e3")])).to_mdx()

        values = self.tm1.cubes.cells.execute_mdx_values(mdx)
        self.assertEqual(next(values), 2)
        self.assertEqual(next(values), 4)
        self.assertEqual(next(values), 6)
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_execute_view_rows_and_values_two_dimensions_on_rows(self):
        view_name = PREFIX + "MDX_View_With_Two_Dim_On_Rows"
        if not self.tm1.cubes.views.exists(cube_name=CUBE_NAME, view_name=view_name, private=False):
            mdx = MdxBuilder.from_cube(CUBE_NAME).add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
                Member.of(DIMENSION_NAMES[0], "Element1"),
                Member.of(DIMENSION_NAMES[0], "Element2")])) \
                .add_hierarchy_set_to_row_axis(MdxHierarchySet.members([
                Member.of(DIMENSION_NAMES[1], "Element1"),
                Member.of(DIMENSION_NAMES[1], "Element2")])) \
                .add_hierarchy_set_to_column_axis(MdxHierarchySet.members([
                Member.of(DIMENSION_NAMES[2], "Element1"),
                Member.of(DIMENSION_NAMES[2], "Element2"),
                Member.of(DIMENSION_NAMES[2], "Element3")])) \
                .where(Member.of(DIMENSION_NAMES[2], "Element1")) \
                .to_mdx()

            view = MDXView(cube_name=CUBE_NAME, view_name=view_name, MDX=mdx)
            self.tm1.cubes.views.create(view, False)

        data = self.tm1.cubes.cells.execute_view_rows_and_values(