diff --git a/data/2020SU11 Blog Demo - November.pbix b/data/2020SU11 Blog Demo - November.pbix new file mode 100644 index 00000000..ded18199 Binary files /dev/null and b/data/2020SU11 Blog Demo - November.pbix differ diff --git a/data/output/metadata.sqlitedb b/data/output/metadata.sqlitedb new file mode 100644 index 00000000..bf7e4f70 Binary files /dev/null and b/data/output/metadata.sqlitedb differ diff --git a/demo.py b/demo.py index a51d4cb7..413afdc3 100644 --- a/demo.py +++ b/demo.py @@ -36,4 +36,17 @@ ic(model.size) ic(model.schema) ic(model.relationships) -ic(model.get_table("Fruit_RLE")) \ No newline at end of file +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")) \ No newline at end of file diff --git a/pbixray/core.py b/pbixray/core.py index d240dd11..a60463ce 100644 --- a/pbixray/core.py +++ b/pbixray/core.py @@ -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 diff --git a/pbixray/meta/metadata_query.py b/pbixray/meta/metadata_query.py index 1279e81f..0503d716 100644 --- a/pbixray/meta/metadata_query.py +++ b/pbixray/meta/metadata_query.py @@ -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): @@ -80,8 +81,20 @@ 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 @@ -89,7 +102,7 @@ def populate_metadata(self): """ return self.handler.execute_query(sql) - def populate_relationships(self): + def __populate_relationships(self): sql = """ SELECT ft.Name AS FromTableName,