Skip to content

Commit

Permalink
first stab at dax columns
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugoberry committed Dec 11, 2024
1 parent b17f5e3 commit e4bf548
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 5 deletions.
Binary file added data/2020SU11 Blog Demo - November.pbix
Binary file not shown.
Binary file added data/output/metadata.sqlitedb
Binary file not shown.
15 changes: 14 additions & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@
ic(model.size)
ic(model.schema)
ic(model.relationships)
ic(model.get_table("Fruit_RLE"))
ic(model.get_table("Fruit_RLE"))

model = PBIXRay(r"C:\git\hub\pbixray\data\2020SU11 Blog Demo - November.pbix")
ic(model.tables)
ic(model.metadata)
ic(model.power_query)
ic(model.statistics)
ic(model.dax_tables)
ic(model.dax_measures)
ic(model.dax_columns)
ic(model.size)
ic(model.schema)
ic(model.relationships)
ic(model.get_table("Product"))
4 changes: 4 additions & 0 deletions pbixray/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def dax_tables(self):
def dax_measures(self):
return self._metadata_handler.metadata.dax_measures_df

@property
def dax_columns(self):
return self._metadata_handler.metadata.dax_columns_df

@property
def metadata(self):
return self._metadata_handler.metadata.metadata_df
Expand Down
21 changes: 17 additions & 4 deletions pbixray/meta/metadata_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ def __init__(self, sqlite_handler):
self.m_df = self.__populate_m()
self.dax_tables_df = self.__populate_dax_tables()
self.dax_measures_df = self.__populate_dax_measures()
self.metadata_df = self.populate_metadata()
self.relationships_df = self.populate_relationships()
self.dax_columns_df = self.__populate_dax_columns()
self.metadata_df = self.__populate_metadata()
self.relationships_df = self.__populate_relationships()
self.handler.close_connection()

def __populate_schema(self):
Expand Down Expand Up @@ -80,16 +81,28 @@ def __populate_dax_measures(self):
JOIN [Table] t ON m.TableID = t.ID;
"""
return self.handler.execute_query(sql)

def __populate_dax_columns(self):
sql = """
SELECT
t.Name AS TableName,
c.ExplicitName AS ColumnName,
c.Expression
FROM Column c
JOIN [Table] t ON c.TableID = t.ID
WHERE c.Type = 2;
"""
return self.handler.execute_query(sql)

def populate_metadata(self):
def __populate_metadata(self):
sql = """
SELECT Name,Value
FROM Annotation
WHERE ObjectType = 1
"""
return self.handler.execute_query(sql)

def populate_relationships(self):
def __populate_relationships(self):
sql = """
SELECT
ft.Name AS FromTableName,
Expand Down

0 comments on commit e4bf548

Please sign in to comment.