Skip to content

Checking for Unused Dimension Elements Before Deletion #1055

Answered by Sven-Bo
Sven-Bo asked this question in Q&A
Discussion options

You must be logged in to vote

I have a working script, but it's quite basic. It just checks for a specific dimension and element, counting how many values it finds in the cubes. However, it doesn't handle errors, such as if the dimension or element doesn't exist. Here's what I've put together:

from mdxpy import MdxBuilder, MdxHierarchySet, Member
from TM1py.Services import TM1Service


def build_mdx_query(cube_name, excluded_dimension, element_to_check, dimensions):
    """
    Constructs an MDX query to find usage of a specific element in a dimension.
    """
    query = MdxBuilder.from_cube(cube_name).columns_non_empty().rows_non_empty()
    query.add_hierarchy_set_to_axis(
        0, MdxHierarchySet.member(Member.of(

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Sven-Bo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants