How to use the mdxpy.MdxHierarchySet.member 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
def test_read_write_with_custom_encoding_fail_response_encoding(self):
        coordinates = ("d1e1", "d2e2", "d3e3")
        self.tm1.cubes.cells.write_values(STRING_CUBE_NAME, {coordinates: LATIN_1_ENCODED_TEXT}, encoding="latin-1")

        mdx = MdxBuilder.from_cube(STRING_CUBE_NAME) \
            .add_hierarchy_set_to_column_axis(
            MdxHierarchySet.member(Member.of(STRING_DIMENSION_NAMES[0], coordinates[0]))) \
            .add_hierarchy_set_to_column_axis(
            MdxHierarchySet.member(Member.of(STRING_DIMENSION_NAMES[1], coordinates[1]))) \
            .add_hierarchy_set_to_column_axis(
            MdxHierarchySet.member(Member.of(STRING_DIMENSION_NAMES[2], coordinates[2]))) \
            .to_mdx()

        values = self.tm1.cubes.cells.execute_mdx_values(mdx=mdx)

        self.assertNotEqual(LATIN_1_ENCODED_TEXT, next(values))
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_execute_mdx_skip_contexts(self):
        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "Element1"))) \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "Element1"))) \
            .add_member_to_where("[" + DIMENSION_NAMES[2] + "].[Element1]").to_mdx()

        data = self.tm1.cubes.cells.execute_mdx(mdx, skip_contexts=True)

        self.assertEqual(len(data), 1)
        for coordinates, cell in data.items():
            self.assertEqual(len(coordinates), 2)
            self.assertEqual(
                Utils.dimension_name_from_element_unique_name(coordinates[0]),
                DIMENSION_NAMES[0])
            self.assertEqual(
                Utils.dimension_name_from_element_unique_name(coordinates[1]),
                DIMENSION_NAMES[1])
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_execute_mdx_rows_and_values_empty_cellset(self):
        # make sure it's empty
        self.tm1.cubes.cells.write_values(CUBE_NAME, {("Element10", "Element11", "Element13"): 0})

        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .rows_non_empty() \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "Element10"))) \
            .columns_non_empty() \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "Element11"))) \
            .add_member_to_where("[" + DIMENSION_NAMES[2] + "].[Element13]").to_mdx()

        data = self.tm1.cubes.cells.execute_mdx_rows_and_values(mdx, element_unique_names=True)
        self.assertEqual(len(data), 0)
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_execute_mdx_rows_and_values_empty_cellset(self):
        # make sure it's empty
        self.tm1.cubes.cells.write_values(CUBE_NAME, {("Element10", "Element11", "Element13"): 0})

        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .rows_non_empty() \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "Element10"))) \
            .columns_non_empty() \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "Element11"))) \
            .add_member_to_where("[" + DIMENSION_NAMES[2] + "].[Element13]").to_mdx()

        data = self.tm1.cubes.cells.execute_mdx_rows_and_values(mdx, element_unique_names=True)
        self.assertEqual(len(data), 0)
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_clear_with_mdx_happy_case(self):
        cells = {("Element17", "Element21", "Element15"): 1}
        self.tm1.cells.write_values(CUBE_NAME, cells)

        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "Element17"))) \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "Element21"))) \
            .where(Member.of(DIMENSION_NAMES[2], "Element15")) \
            .to_mdx()

        self.tm1.cells.clear_with_mdx(cube=CUBE_NAME, mdx=mdx)

        value = next(self.tm1.cells.execute_mdx_values(mdx=mdx))
        self.assertEqual(value, None)
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_execute_mdx_csv_empty_cellset(self):
        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .rows_non_empty() \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "Element9"))) \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "Element 18"))) \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[2], "Element 2"))) \
            .to_mdx()

        csv = self.tm1.cubes.cells.execute_mdx_csv(mdx)

        self.assertEqual("", csv)
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_RPS2_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_RPS2_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_mdx_rows_and_values_member_names(self):
        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "Element1"))) \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "Element1"))) \
            .add_member_to_where("[" + DIMENSION_NAMES[2] + "].[Element1]").to_mdx()

        data = self.tm1.cubes.cells.execute_mdx_rows_and_values(mdx, element_unique_names=False)

        self.assertEqual(len(data), 1)
        for row, cells in data.items():
            member_name = row[0]
            self.assertEqual(member_name, "Element 1")
github cubewise-code / tm1py / Tests / Cell.py View on Github external
def test_write_values_through_cellset(self):
        mdx = MdxBuilder.from_cube(CUBE_NAME) \
            .add_hierarchy_set_to_row_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[0], "element2"))) \
            .add_hierarchy_set_to_column_axis(MdxHierarchySet.member(Member.of(DIMENSION_NAMES[1], "element2"))) \
            .where(Member.of(DIMENSION_NAMES[2], "element2")) \
            .to_mdx()

        original_value = next(self.tm1.cubes.cells.execute_mdx_values(mdx))

        self.tm1.cubes.cells.write_values_through_cellset(mdx, (1.5,))

        # check value on coordinate in cube
        values = self.tm1.cubes.cells.execute_mdx_values(mdx)
        self.assertEqual(next(values), 1.5)

        self.tm1.cubes.cells.write_values_through_cellset(mdx, (original_value,))