sempy_labs package
Subpackages
- sempy_labs.directlake package
- Module contents
check_fallback_reason()direct_lake_schema_compare()direct_lake_schema_sync()get_direct_lake_guardrails()get_direct_lake_lakehouse()get_directlake_guardrails_for_sku()get_shared_expression()get_sku_size()list_direct_lake_model_calc_tables()show_unsupported_direct_lake_objects()update_direct_lake_model_lakehouse_connection()update_direct_lake_partition_entity()warm_direct_lake_cache_isresident()warm_direct_lake_cache_perspective()
- Module contents
- sempy_labs.lakehouse package
- sempy_labs.migration package
- sempy_labs.report package
Module contents
- class sempy_labs.TOMWrapper(dataset, workspace, readonly)
Bases:
objectConvenience wrapper around the TOM object model for a semantic model. Always use connect_semantic_model function to make sure the TOM object is initialized correctly.
- add_calculated_column(table_name: str, column_name: str, expression: str, data_type: str, format_string: str | None = None, hidden: bool | None = False, description: str | None = None, display_folder: str | None = None, data_category: str | None = None, key: bool | None = False, summarize_by: str | None = None)
Adds a calculated column to a table within a semantic model.
- Parameters:
table_name (str) – Name of the table in which the column will be created.
column_name (str) – Name of the column.
expression (str) – The DAX expression for the column.
data_type (str) – The data type of the column.
format_string (str, default=None) – Format string of the column.
hidden (bool, default=False) – Whether the column will be hidden or visible.
description (str, default=None) – A description of the column.
display_folder (str, default=None) – The display folder in which the column will reside.
data_category (str, default=None) – The data category of the column.
key (bool, default=False) – Marks the column as the primary key of the table.
summarize_by (str, default=None) – Sets the value for the Summarize By property of the column. Defaults to None resolves to ‘Default’.
- add_calculated_table(name: str, expression: str, description: str | None = None, data_category: str | None = None, hidden: bool | None = False)
Adds a calculated table to the semantic model.
- Parameters:
- add_calculated_table_column(table_name: str, column_name: str, source_column: str, data_type: str, format_string: str | None = None, hidden: bool | None = False, description: str | None = None, display_folder: str | None = None, data_category: str | None = None, key: bool | None = False, summarize_by: str | None = None)
Adds a calculated table column to a calculated table within a semantic model.
- Parameters:
table_name (str) – Name of the table in which the column will be created.
column_name (str) – Name of the column.
source_column (str) – The source column for the column.
data_type (str) – The data type of the column.
format_string (str, default=None) – Format string of the column.
hidden (bool, default=False) – Whether the column will be hidden or visible.
description (str, default=None) – A description of the column.
display_folder (str, default=None) – The display folder in which the column will reside.
data_category (str, default=None) – The data category of the column.
key (bool, default=False) – Marks the column as the primary key of the table.
summarize_by (str, default=None) – Sets the value for the Summarize By property of the column. Defaults to None resolves to ‘Default’.
- add_calculation_group(name: str, precedence: int, description: str | None = None, hidden: bool | None = False)
Adds a calculation group to a semantic model.
- add_calculation_item(table_name: str, calculation_item_name: str, expression: str, ordinal: int | None = None, format_string_expression: str | None = None, description: str | None = None)
Adds a calculation item to a calculation group within a semantic model.
- Parameters:
table_name (str) – Name of the table in which the calculation item will be created.
calculation_item_name (str) – Name of the calculation item.
expression (str) – The DAX expression for the calculation item.
ordinal (int, default=None) – The ordinal of the calculation item.
format_string_expression (str, default=None) – The format string expression for the calculation item.
description (str, default=None) – A description of the calculation item.
- add_data_column(table_name: str, column_name: str, source_column: str, data_type: str, format_string: str | None = None, hidden: bool | None = False, description: str | None = None, display_folder: str | None = None, data_category: str | None = None, key: bool | None = False, summarize_by: str | None = None)
Adds a data column to a table within a semantic model.
- Parameters:
table_name (str) – Name of the table in which the column will be created.
column_name (str) – Name of the column.
source_column (str) – The source column for the column.
data_type (str) – The data type of the column.
format_string (str, default=None) – Format string of the column.
hidden (bool, default=False) – Whether the column will be hidden or visible.
description (str, default=None) – A description of the column.
display_folder (str, default=None) – The display folder in which the column will reside.
data_category (str, default=None) – The data category of the column.
key (bool, default=False) – Marks the column as the primary key of the table.
summarize_by (str, default=None) – Sets the value for the Summarize By property of the column. Defaults to None resolves to ‘Default’.
- add_entity_partition(table_name: str, entity_name: str, expression: str | None = None, description: str | None = None)
Adds an entity partition to a table within a semantic model.
- Parameters:
- add_expression(name: str, expression: str, description: str | None = None)
Adds an expression to a semantic model.
- add_hierarchy(table_name: str, hierarchy_name: str, columns: List[str], levels: List[str] | None = None, hierarchy_description: str | None = None, hierarchy_hidden: bool | None = False)
Adds a hierarchy to a table within a semantic model.
- Parameters:
table_name (str) – Name of the table.
hierarchy_name (str) – Name of the hierarchy.
columns (List[str]) – Names of the columns to use within the hierarchy.
levels (List[str], default=None) – Names of the levels to use within the hierarhcy (instead of the column names).
hierarchy_description (str, default=None) – A description of the hierarchy.
hierarchy_hidden (bool, default=False) – Whether the hierarchy is visible or hidden.
- add_incremental_refresh_policy(table_name: str, column_name: str, start_date: str, end_date: str, incremental_granularity: str, incremental_periods: int, rolling_window_granularity: str, rolling_window_periods: int, only_refresh_complete_days: bool | None = False, detect_data_changes_column: str | None = None)
Adds anincremental refresh policy for a table within a semantic model.
- Parameters:
table_name (str) – Name of the table.
column_name (str) – The DateTime column to be used for the RangeStart and RangeEnd parameters.
start_date (str) – The date to be used for the RangeStart parameter.
end_date (str) – The date to be used for the RangeEnd parameter.
incremental_granularity (str) – Granularity of the (most recent) incremental refresh range.
incremental_periods (int) – Number of periods for the incremental refresh range.
rolling_window_granularity (str) – Target granularity of the rolling window for the whole semantic model.
rolling_window_periods (int) – Number of periods for the rolling window for the whole semantic model.
only_refresh_complete_days (bool, default=False) – Lag or leading periods from Now() to the rolling window head.
detect_data_changes_column (str, default=None) – The column to use for detecting data changes. Defaults to None which resolves to not detecting data changes.
- add_m_partition(table_name: str, partition_name: str, expression: str, mode: str | None = None, description: str | None = None)
Adds an M-partition to a table within a semantic model.
- Parameters:
table_name (str) – Name of the table.
partition_name (str) – Name of the partition.
expression (str) – The M expression encapsulating the logic for the partition.
mode (str, default=None) – The query mode for the partition. Defaults to None which resolves to ‘Import’.
description (str, default=None) – A description for the partition.
- add_measure(table_name: str, measure_name: str, expression: str, format_string: str | None = None, hidden: bool | None = False, description: str | None = None, display_folder: str | None = None)
Adds a measure to the semantic model.
- Parameters:
table_name (str) – Name of the table in which the measure will be created.
measure_name (str) – Name of the measure.
expression (str) – DAX expression of the measure.
format_string (str, default=None) – Format string of the measure.
hidden (bool, default=False) – Whether the measure will be hidden or visible.
description (str, default=None) – A description of the measure.
display_folder (str, default=None) – The display folder in which the measure will reside.
- add_perspective(perspective_name: str)
Adds a perspective to a semantic model.
- Parameters:
perspective_name (str) – Name of the perspective.
- add_relationship(from_table: str, from_column: str, to_table: str, to_column: str, from_cardinality: str, to_cardinality: str, cross_filtering_behavior: str | None = None, is_active: bool | None = True, security_filtering_behavior: str | None = None, rely_on_referential_integrity: bool | None = False)
Adds a relationship to a semantic model.
- Parameters:
from_table (str) – Name of the table on the ‘from’ side of the relationship.
from_column (str) – Name of the column on the ‘from’ side of the relationship.
to_table (str) – Name of the table on the ‘to’ side of the relationship.
to_column (str) – Name of the column on the ‘to’ side of the relationship.
from_cardinality (str) – The cardinality of the ‘from’ side of the relationship. Options: [‘Many’, ‘One’, ‘None’].
to_cardinality (str) – The cardinality of the ‘to’ side of the relationship. Options: [‘Many’, ‘One’, ‘None’].
cross_filtering_behavior (str, default=None) – Setting for the cross filtering behavior of the relationship. Options: (‘Automatic’, ‘OneDirection’, ‘BothDirections’). Defaults to None which resolves to ‘Automatic’.
is_active (bool, default=True) – Setting for whether the relationship is active or not.
security_filtering_behavior (str, default=None) – Setting for the security filtering behavior of the relationship. Options: (‘None’, ‘OneDirection’, ‘BothDirections’). Defaults to None which resolves to ‘OneDirection’.
rely_on_referential_integrity (bool, default=False) – Setting for the rely on referential integrity of the relationship.
- add_role(role_name: str, model_permission: str | None = None, description: str | None = None)
Adds a role to a semantic model.
- add_table(name: str, description: str | None = None, data_category: str | None = None, hidden: bool | None = False)
Adds a table to the semantic model.
- add_time_intelligence(measure_name: str, date_table: str, time_intel: str | List[str])
Adds time intelligence measures
- add_to_perspective(object: TOM.Table | TOM.Column | TOM.Measure | TOM.Hierarchy, perspective_name: str)
Adds an object to a perspective.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
perspective_name (str) – Name of the perspective.
- add_translation(language: str)
Adds a translation language (culture) to a semantic model.
- Parameters:
language (str) – The language code (i.e. ‘it-IT’ for Italian).
- all_calculated_columns()
Outputs a list of all calculated columns within all tables in the semantic model.
- Returns:
All calculated columns within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Column]
- all_calculated_tables()
Outputs a list of all calculated tables in the semantic model.
- Returns:
All calculated tables within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Table]
- all_calculation_groups()
Outputs a list of all calculation groups in the semantic model.
- Returns:
All calculation groups within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Table]
- all_calculation_items()
Outputs a list of all calculation items in the semantic model.
- Returns:
All calculation items within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.CalculationItem]
- all_columns()
Outputs a list of all columns within all tables in the semantic model.
- Returns:
All columns within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Column]
- all_hierarchies()
Outputs a list of all hierarchies in the semantic model.
- Returns:
All hierarchies within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Hierarchy]
- all_levels()
Outputs a list of all levels in the semantic model.
- Returns:
All levels within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Level]
- all_measures()
Outputs a list of all measures in the semantic model.
- Returns:
All measures within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Measure]
- all_partitions()
Outputs a list of all partitions in the semantic model.
- Returns:
All partitions within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.Partition]
- all_rls()
Outputs a list of all row level security expressions in the semantic model.
- Returns:
All row level security expressions within the semantic model.
- Return type:
Iterator[Microsoft.AnalysisServices.Tabular.TablePermission]
- apply_refresh_policy(table_name: str, effective_date: datetime | None = None, refresh: bool | None = True, max_parallelism: int | None = 0)
Applies the incremental refresh policy for a table within a semantic model.
- Parameters:
table_name (str) – Name of the table.
effective_date (DateTime, default=None) – The effective date that is used when calculating the partitioning scheme.
refresh (bool, default=True) – An indication if partitions of the table should be refreshed or not; the default behavior is to do the refresh.
max_parallelism (int, default=0) – The degree of parallelism during the refresh execution.
- cardinality(column: TOM.Column)
Obtains the cardinality of a column within a semantic model.
- Parameters:
column (TOM Object) – The column object within the semantic model.
- Returns:
Cardinality of the TOM column.
- Return type:
- clear_annotations(object)
Removes all annotations on an object within the semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
- clear_extended_properties(object)
Removes all extended properties on an object within the semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
- close()
- data_size(column: TOM.Column)
Obtains the data size of a column within a semantic model.
- Parameters:
column (TOM Object) – The column object within the semantic model.
- Returns:
Data size of the TOM column.
- Return type:
- date_tables()
Outputs the tables which are marked as date tables within a semantic model.
- Returns:
All tables marked as date tables within a semantic model.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection
- depends_on(object, dependencies: DataFrame)
Obtains the objects on which the specified object depends.
- Parameters:
object (TOM Object) – The TOM object within the semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Returns:
Objects on which the specified object depends.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection, Microsoft.AnalysisServices.Tabular.ColumnCollection, Microsoft.AnalysisServices.Tabular.MeasureCollection
- dictionary_size(column: TOM.Column)
Obtains the dictionary size of a column within a semantic model.
- Parameters:
column (TOM Object) – The column object within the semantic model.
- Returns:
Dictionary size of the TOM column.
- Return type:
- fully_qualified_measures(object: TOM.Measure, dependencies: DataFrame)
Obtains all fully qualified measure references for a given object.
- Parameters:
object (TOM Object) – The TOM object within the semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Returns:
All fully qualified measure references for a given object.
- Return type:
Microsoft.AnalysisServices.Tabular.MeasureCollection
- get_annotation_value(object, name: str)
Obtains the annotation value for a given annotation on an object within the semantic model.
- get_annotations(object) Microsoft.AnalysisServices.Tabular.Annotation
Shows all annotations for a given object within a semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
- Returns:
TOM objects of all the annotations on a particular object within the semantic model.
- Return type:
Microsoft.AnalysisServices.Tabular.Annotation
- get_extended_properties(object) Microsoft.AnalysisServices.Tabular.ExtendedProperty
Retrieves all extended properties on an object within the semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
- Returns:
TOM Objects of all the extended properties.
- Return type:
Microsoft.AnalysisServices.Tabular.ExtendedPropertiesCollection
- get_extended_property_value(object, name: str)
Retrieves the value of an extended property for an object within the semantic model.
- has_aggs()
Identifies if a semantic model has any aggregations.
- Returns:
Indicates if the semantic model has any aggregations.
- Return type:
- has_date_table()
Identifies if a semantic model has a table marked as a date table.
- Returns:
Indicates if the semantic model has a table marked as a date table.
- Return type:
- has_hybrid_table()
Identifies if a semantic model has a hybrid table.
- Returns:
Indicates if the semantic model has a hybrid table.
- Return type:
- has_incremental_refresh_policy(table_name: str)
Identifies whether a table has an incremental refresh policy.
- hybrid_tables()
Outputs the hybrid tables within a semantic model.
- Returns:
All hybrid tables within a semantic model.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection
- in_perspective(object: TOM.Table | TOM.Column | TOM.Measure | TOM.Hierarchy, perspective_name: str)
Indicates whether an object is contained within a given perspective.
- is_direct_lake()
Identifies if a semantic model is in Direct Lake mode.
- Returns:
Indicates if the semantic model is in Direct Lake mode.
- Return type:
- is_direct_lake_using_view()
Identifies whether a semantic model is in Direct lake mode and uses views from the lakehouse.
- Returns:
An indicator whether a semantic model is in Direct lake mode and uses views from the lakehouse.
- Return type:
- records_per_segment(object: TOM.Partition)
Obtains the records per segment of a partition within a semantic model.
- Parameters:
object (TOM Object) – The partition object within the semantic model.
- Returns:
Number of records per segment within the partition.
- Return type:
- referenced_by(object, dependencies: DataFrame)
Obtains the objects which reference the specified object.
- Parameters:
object (TOM Object) – The TOM object within the semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Returns:
Objects which reference the specified object.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection, Microsoft.AnalysisServices.Tabular.ColumnCollection, Microsoft.AnalysisServices.Tabular.MeasureCollection
- remove_alternate_of(table_name: str, column_name: str)
Removes the ‘alternate of’ property on a column.
- remove_annotation(object, name: str)
Removes an annotation on an object within the semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
name (str) – Name of the annotation.
- remove_extended_property(object, name: str)
Removes an extended property on an object within the semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
name (str) – Name of the annotation.
- remove_from_perspective(object: TOM.Table | TOM.Column | TOM.Measure | TOM.Hierarchy, perspective_name: str)
Removes an object from a perspective.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
perspective_name (str) – Name of the perspective.
- remove_object(object)
Removes an object from a semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
- remove_translation(object: TOM.Table | TOM.Column | TOM.Measure | TOM.Hierarchy, language: str)
Removes an object’s translation value.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
language (str) – The language code.
- remove_vertipaq_annotations()
Removes the annotations set using the [set_vertipaq_annotations] function.
- row_count(object: TOM.Partition | TOM.Table)
Obtains the row count of a table or partition within a semantic model.
- Parameters:
object (TOM Object) – The table/partition object within the semantic model.
- Returns:
Number of rows within the TOM object.
- Return type:
- set_aggregations(table_name: str, agg_table_name: str)
Sets the aggregations (alternate of) for all the columns in an aggregation table based on a base table.
- set_alternate_of(table_name: str, column_name: str, summarization_type: str, base_table: str, base_column: str | None = None)
Sets the ‘alternate of’ property on a column.
- Parameters:
- set_annotation(object, name: str, value: str)
Sets an annotation on an object within the semantic model.
- set_data_coverage_definition(table_name: str, partition_name: str, expression: str)
Sets the data coverage definition for a partition.
- set_data_type(table_name: str, column_name: str, value: str)
Sets the data type for a column.
- Parameters:
table_name (str) – Name of the table.
column_name (str) – Name of the column.
value (str) – The data type. Data type valid values
- set_direct_lake_behavior(direct_lake_behavior: str)
Sets the Direct Lake Behavior property for a semantic model.
- Parameters:
direct_lake_behavior (str) – The DirectLakeBehavior property value. DirectLakeBehavior valid values
- set_encoding_hint(table_name: str, column_name: str, value: str)
Sets the encoding hint for a column.
- Parameters:
table_name (str) – Name of the table.
column_name (str) – Name of the column.
value (str) – Encoding hint value. Encoding hint valid values
- set_extended_property(object, extended_property_type: str, name: str, value: str)
Sets an extended property on an object within the semantic model.
- Parameters:
object (TOM Object) – An object (i.e. table/column/measure) within a semantic model.
extended_property_type (str) – The extended property type. Extended property valid values
name (str) – Name of the extended property.
value (str) – Value of the extended property.
- set_is_available_in_mdx(table_name: str, column_name: str, value: bool | None = False)
Sets the IsAvailableInMdx property on a column.
- set_kpi(measure_name: str, target: int | float | str, lower_bound: float, upper_bound: float, lower_mid_bound: float | None = None, upper_mid_bound: float | None = None, status_type: str | None = None, status_graphic: str | None = None)
Sets the properties to add/update a KPI for a measure.
- Parameters:
measure_name (str) – Name of the measure.
target (str, int, float) – The target for the KPI. This can either be a number or the name of a different measure in the semantic model.
lower_bound (float) – The lower bound for the KPI.
upper_bound (float) – The upper bound for the KPI.
lower_mid_bound (float, default=None) – The lower-mid bound for the KPI. Set this if status_type is ‘Centered’ or ‘CenteredReversed’.
upper_mid_bound (float, default=None) – The upper-mid bound for the KPI. Set this if status_type is ‘Centered’ or ‘CenteredReversed’.
status_type (str, default=None) – The status type of the KPI. Options: ‘Linear’, ‘LinearReversed’, ‘Centered’, ‘CenteredReversed’. Defaults to None which resolvs to ‘Linear’.
status_graphic (str, default=None) – The status graphic for the KPI. Defaults to ‘Three Circles Colored’.
- set_ols(role_name: str, table_name: str, column_name: str, permission: str)
Sets the object level security permissions for a column within a role.
- Parameters:
role_name (str) – Name of the role.
table_name (str) – Name of the table.
column_name (str) – Name of the column.
permission (str) – The object level security permission for the column. Permission valid values
- set_rls(role_name: str, table_name: str, filter_expression: str)
Sets the row level security permissions for a table within a role.
- set_summarize_by(table_name: str, column_name: str, value: str | None = None)
Sets the SummarizeBy property on a column.
- Parameters:
table_name (str) – Name of the table.
column_name (str) – Name of the column.
value (bool, default=None) – The SummarizeBy property value. Defaults to none which resolves to ‘Default’. Aggregate valid values
- set_translation(object: TOM.Table | TOM.Column | TOM.Measure | TOM.Hierarchy, language: str, property: str, value: str)
Sets a translation value for an object’s property.
- set_vertipaq_annotations()
Saves Vertipaq Analyzer statistics as annotations on objects in the semantic model.
- show_incremental_refresh_policy(table_name: str)
Prints the incremental refresh policy for a table.
- Parameters:
table_name (str) – Name of the table.
- total_size(object: TOM.Table | TOM.Column)
Obtains the data size of a table/column within a semantic model.
- Parameters:
object (TOM Object) – The table/column object within the semantic model.
- Returns:
Total size of the TOM table/column.
- Return type:
- unqualified_columns(object: TOM.Column, dependencies: DataFrame)
Obtains all unqualified column references for a given object.
- Parameters:
object (TOM Object) – The TOM object within the semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Returns:
All unqualified column references for a given object.
- Return type:
Microsoft.AnalysisServices.Tabular.ColumnCollection
- update_incremental_refresh_policy(table_name: str, incremental_granularity: str, incremental_periods: int, rolling_window_granularity: str, rolling_window_periods: int, only_refresh_complete_days: bool | None = False, detect_data_changes_column: str | None = None)
Updates the incremental refresh policy for a table within a semantic model.
- Parameters:
table_name (str) – Name of the table.
incremental_granularity (str) – Granularity of the (most recent) incremental refresh range.
incremental_periods (int) – Number of periods for the incremental refresh range.
rolling_window_granularity (str) – Target granularity of the rolling window for the whole semantic model.
rolling_window_periods (int) – Number of periods for the rolling window for the whole semantic model.
only_refresh_complete_days (bool, default=False) – Lag or leading periods from Now() to the rolling window head.
detect_data_changes_column (str, default=None) – The column to use for detecting data changes. Defaults to None which resolves to not detecting data changes.
- used_in_calc_item(object: TOM.Table | TOM.Column | TOM.Measure, dependencies: DataFrame)
Identifies the … which reference a given object.
- Parameters:
object (TOM Object) – An object (i.e. table/column) within a semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection, Microsoft.AnalysisServices.Tabular.ColumnCollection, Microsoft.AnalysisServices.Tabular.MeasureCollection
- used_in_data_coverage_definition(object: TOM.Table | TOM.Column | TOM.Measure, dependencies: DataFrame)
Identifies the … which reference a given object.
- Parameters:
object (TOM Object) – An object (i.e. table/column) within a semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection, Microsoft.AnalysisServices.Tabular.ColumnCollection, Microsoft.AnalysisServices.Tabular.MeasureCollection
- used_in_hierarchies(column: TOM.Column)
Shows all hierarchies in which a column is used.
- Parameters:
object (TOM Object) – An column object within a semantic model.
- Returns:
All hierarchies in which the column is used.
- Return type:
Microsoft.AnalysisServices.Tabular.HierarchyCollection
- used_in_levels(column: TOM.Column)
Shows all levels in which a column is used.
- Parameters:
object (TOM Object) – An column object within a semantic model.
- Returns:
All levels in which the column is used.
- Return type:
Microsoft.AnalysisServices.Tabular.LevelCollection
- used_in_relationships(object: TOM.Table | TOM.Column)
Shows all relationships in which a table/column is used.
- Parameters:
object (TOM Object) – An object (i.e. table/column) within a semantic model.
- Returns:
All relationships in which the table/column is used.
- Return type:
Microsoft.AnalysisServices.Tabular.RelationshipCollection
- used_in_rls(object: TOM.Table | TOM.Column | TOM.Measure, dependencies: DataFrame)
Identifies the filter expressions which reference a given object.
- Parameters:
object (TOM Object) – An object (i.e. table/column) within a semantic model.
dependencies (pandas.DataFrame) – A pandas dataframe with the output of the ‘get_model_calc_dependencies’ function.
- Return type:
Microsoft.AnalysisServices.Tabular.TableCollection, Microsoft.AnalysisServices.Tabular.ColumnCollection, Microsoft.AnalysisServices.Tabular.MeasureCollection
- used_in_sort_by(column: TOM.Column)
Shows all columns in which a column is used for sorting.
- Parameters:
object (TOM Object) – An column object within a semantic model.
- Returns:
All columns in which the column is used for sorting.
- Return type:
Microsoft.AnalysisServices.Tabular.ColumnCollection
- used_size(object: TOM.Hierarchy | TOM.Relationship)
Obtains the used size of a hierarchy or relationship within a semantic model.
- Parameters:
object (TOM Object) – The hierarhcy/relationship object within the semantic model.
- Returns:
Used size of the TOM object.
- Return type:
- sempy_labs.cancel_dataset_refresh(dataset: str, request_id: str | None = None, workspace: str | None = None)
Cancels the refresh of a semantic model which was executed via the Enhanced Refresh API
- Parameters:
dataset (str) – Name of the semantic model.
request_id (str, default=None) – The request id of a semantic model refresh. Defaults to finding the latest active refresh of the semantic model.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.clear_cache(dataset: str, workspace: str | None = None)
Clears the cache of a semantic model.
- sempy_labs.connect_semantic_model(dataset: str, readonly: bool = True, workspace: str | None = None)
Connects to the Tabular Object Model (TOM) within a semantic model.
- Parameters:
dataset (str) – Name of the semantic model.
readonly (bool, default=True) – Whether the connection is read-only or read/write. Setting this to False enables read/write which saves the changes made back to the server.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
A connection to the semantic model’s Tabular Object Model.
- Return type:
- sempy_labs.create_abfss_path(lakehouse_id: UUID, lakehouse_workspace_id: UUID, delta_table_name: str)
Creates an abfss path for a delta table in a Fabric lakehouse.
- sempy_labs.create_blank_semantic_model(dataset: str, compatibility_level: int = 1605, workspace: str | None = None)
Creates a new blank semantic model (no tables/columns etc.).
- Parameters:
dataset (str) – Name of the semantic model.
compatibility_level (int) – The compatibility level of the semantic model. Defaults to 1605.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.create_relationship_name(from_table: str, from_column: str, to_table: str, to_column: str)
Formats a relationship’s table/columns into a fully qualified name.
- Parameters:
from_table (str) – The name of the table on the ‘from’ side of the relationship.
from_column (str) – The name of the column on the ‘from’ side of the relationship.
to_table (str) – The name of the table on the ‘to’ side of the relationship.
to_column (str) – The name of the column on the ‘to’ side of the relationship.
- Returns:
The fully qualified relationship name.
- Return type:
- sempy_labs.create_semantic_model_from_bim(dataset: str, bim_file: str, workspace: str | None = None)
Creates a new semantic model based on a Model.bim file.
- sempy_labs.create_warehouse(warehouse: str, description: str | None = None, workspace: str | None = None)
Creates a Fabric warehouse.
- Parameters:
warehouse (str) – Name of the warehouse.
description (str, default=None) – A description of the warehouse.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.export_model_to_onelake(dataset: str, workspace: str | None = None, destination_lakehouse: str | None = None, destination_workspace: str | None = None)
Exports a semantic model’s tables to delta tables in the lakehouse. Creates shortcuts to the tables if a lakehouse is specified.
- Parameters:
dataset (str) – Name of the semantic model.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
destination_lakehouse (str, default=None) – The name of the Fabric lakehouse where shortcuts will be created to access the delta tables created by the export. If the lakehouse specified does not exist, one will be created with that name. If no lakehouse is specified, shortcuts will not be created.
destination_workspace (str, default=None) – The name of the Fabric workspace in which the lakehouse resides.
- sempy_labs.format_dax_object_name(table: str, column: str)
Formats a table/column combination to the ‘Table Name’[Column Name] format.
- sempy_labs.generate_embedded_filter(filter: str)
Converts the filter expression to a filter expression which can be used by a Power BI embedded URL.
- sempy_labs.get_direct_lake_sql_endpoint(dataset: str, workspace: str | None = None) UUID
Obtains the SQL Endpoint ID of the semantic model.
- Parameters:
- Returns:
The ID of SQL Endpoint.
- Return type:
- sempy_labs.get_measure_dependencies(dataset: str, workspace: str | None = None)
Shows all dependencies for all measures in a semantic model.
- Parameters:
- Returns:
Shows all dependencies for all measures in the semantic model.
- Return type:
- sempy_labs.get_model_calc_dependencies(dataset: str, workspace: str | None = None)
Shows all dependencies for all objects in a semantic model.
- Parameters:
- Returns:
Shows all dependencies for all objects in the semantic model.
- Return type:
- sempy_labs.get_object_level_security(dataset: str, workspace: str | None = None)
Shows the object level security for the semantic model.
- Parameters:
- Returns:
A pandas dataframe showing the object level security for the semantic model.
- Return type:
- sempy_labs.get_semantic_model_bim(dataset: str, workspace: str | None = None, save_to_file_name: str | None = None)
Extracts the Model.bim file for a given semantic model.
- Parameters:
dataset (str) – Name of the semantic model.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
save_to_file_name (str, default=None) – If specified, saves the Model.bim as a file in the lakehouse attached to the notebook.
- Returns:
The Model.bim file for the semantic model.
- Return type:
- sempy_labs.import_vertipaq_analyzer(folder_path: str, file_name: str)
Imports and visualizes the vertipaq analyzer info from a saved .zip file in your lakehouse.
- Parameters:
- Returns:
A visualization of the Vertipaq Analyzer statistics.
- Return type:
- sempy_labs.list_dashboards(workspace: str | None = None)
Shows a list of the dashboards within a workspace.
- Parameters:
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
A pandas dataframe showing the dashboards within a workspace.
- Return type:
- sempy_labs.list_dataflow_storage_accounts()
Shows the accessible dataflow storage accounts.
- Returns:
A pandas dataframe showing the accessible dataflow storage accounts.
- Return type:
- sempy_labs.list_lakehouses(workspace: str | None = None)
Shows the lakehouses within a workspace.
- Parameters:
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
A pandas dataframe showing the lakehouses within a workspace.
- Return type:
- sempy_labs.list_warehouses(workspace: str | None = None)
Shows the warehouses within a workspace.
- Parameters:
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
A pandas dataframe showing the warehouses within a workspace.
- Return type:
- sempy_labs.measure_dependency_tree(dataset: str, measure_name: str, workspace: str | None = None)
Prints a measure dependency tree of all dependent objects for a measure in a semantic model.
- Parameters:
- sempy_labs.model_auto_build(dataset: str, file_path: str, workspace: str | None = None, lakehouse: str | None = None, lakehouse_workspace: str | None = None)
Dynamically generates a semantic model based on an Excel file template.
- Parameters:
dataset (str) – Name of the semantic model.
file_path (str)
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
lakehouse (str, default=None) – The Fabric lakehouse used by the Direct Lake semantic model. Defaults to None which resolves to the lakehouse attached to the notebook.
lakehouse_workspace (str, default=None) – The Fabric workspace used by the lakehouse. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.model_bpa_rules()
Shows the default rules for the semantic model BPA used by the run_model_bpa function.
- Returns:
A pandas dataframe containing the default rules for the run_model_bpa function.
- Return type:
- sempy_labs.refresh_semantic_model(dataset: str, tables: str | List[str] | None = None, partitions: str | List[str] | None = None, refresh_type: str | None = None, retry_count: int | None = 0, apply_refresh_policy: bool | None = True, workspace: str | None = None)
Refreshes a semantic model.
- Parameters:
dataset (str) – Name of the semantic model.
tables (str, List[str], default=None) – A string or a list of tables to refresh.
partitions (str, List[str], default=None) – A string or a list of partitions to refresh. Partitions must be formatted as such: ‘Table Name’[Partition Name].
refresh_type (str, default='full') – The type of processing to perform. Types align with the TMSL refresh command types: full, clearValues, calculate, dataOnly, automatic, and defragment. The add type isn’t supported. Defaults to “full”.
retry_count (int, default=0) – Number of times the operation retries before failing.
apply_refresh_policy (bool, default=True) – If an incremental refresh policy is defined, determines whether to apply the policy. Modes are true or false. If the policy isn’t applied, the full process leaves partition definitions unchanged, and fully refreshes all partitions in the table. If commitMode is transactional, applyRefreshPolicy can be true or false. If commitMode is partialBatch, applyRefreshPolicy of true isn’t supported, and applyRefreshPolicy must be set to false.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.resolve_dataset_id(dataset: str, workspace: str | None = None)
Obtains the ID of the semantic model.
- Parameters:
- Returns:
The ID of the semantic model.
- Return type:
UUID
- sempy_labs.resolve_dataset_name(dataset_id: UUID, workspace: str | None = None)
Obtains the name of the semantic model.
- Parameters:
dataset_id (UUID) – The name of the semantic model.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
The name of the semantic model.
- Return type:
- sempy_labs.resolve_lakehouse_id(lakehouse: str, workspace: str | None = None)
Obtains the ID of the Fabric lakehouse.
- Parameters:
- Returns:
The ID of the Fabric lakehouse.
- Return type:
UUID
- sempy_labs.resolve_lakehouse_name(lakehouse_id: UUID, workspace: str | None = None)
Obtains the name of the Fabric lakehouse.
- Parameters:
lakehouse_id (UUID) – The name of the Fabric lakehouse.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
The name of the Fabric lakehouse.
- Return type:
- sempy_labs.resolve_report_id(report: str, workspace: str | None = None)
Obtains the ID of the Power BI report.
- Parameters:
- Returns:
The ID of the Power BI report.
- Return type:
UUID
- sempy_labs.resolve_report_name(report_id: UUID, workspace: str | None = None)
Obtains the name of the Power BI report.
- Parameters:
report_id (UUID) – The name of the Power BI report.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
The name of the Power BI report.
- Return type:
- sempy_labs.run_dax(dataset: str, dax_query: str, user_name: str | None = None, workspace: str | None = None)
Runs a DAX query against a semantic model using the REST API.
Compared to evaluate_dax this allows passing the user name for impersonation. Note that the REST API has significant limitations compared to the XMLA endpoint.
- Parameters:
dataset (str) – Name of the semantic model.
dax_query (str) – The DAX query.
user_name (str) – The user name (i.e. hello@goodbye.com). Defaults to None which resolves to no user impersonation.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
A pandas dataframe holding the result of the DAX query.
- Return type:
- sempy_labs.run_model_bpa(dataset: str, rules_dataframe: DataFrame | None = None, workspace: str | None = None, export: bool | None = False, return_dataframe: bool | None = False, **kwargs)
Displays an HTML visualization of the results of the Best Practice Analyzer scan for a semantic model.
- Parameters:
dataset (str) – Name of the semantic model.
rules_dataframe (pandas.DataFrame, default=None) – A pandas dataframe containing rules to be evaluated.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
export (bool, default=False) – If True, exports the resulting dataframe to a delta table in the lakehouse attached to the notebook.
return_dataframe (bool, default=False) – If True, returns a pandas dataframe instead of the visualization.
- Returns:
A pandas dataframe in HTML format showing semantic model objects which violated the best practice analyzer rules.
- Return type:
- sempy_labs.save_as_delta_table(dataframe, delta_table_name: str, write_mode: str, lakehouse: str | None = None, workspace: str | None = None)
Saves a pandas dataframe as a delta table in a Fabric lakehouse.
- Parameters:
dataframe (pandas.DataFrame) – The dataframe to be saved as a delta table.
delta_table_name (str) – The name of the delta table.
write_mode (str) – The write mode for the save operation. Options: ‘append’, ‘overwrite’.
lakehouse (str, default=None) – The Fabric lakehouse used by the Direct Lake semantic model. Defaults to None which resolves to the lakehouse attached to the notebook.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- Returns:
The ID of the Power BI report.
- Return type:
UUID
- sempy_labs.translate_semantic_model(dataset: str, languages: str | List[str], exclude_characters: str | None = None, workspace: str | None = None)
Translates names, descriptions, display folders for all objects in a semantic model.
- Parameters:
dataset (str) – Name of the semantic model.
languages (str, List[str]) – The language code(s) in which to translate the semantic model.
exclude_characters (str) – A string specifying characters which will be replaced by a space in the translation text when sent to the translation service.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.update_item(item_type: str, current_name: str, new_name: str, description: str | None = None, workspace: str | None = None)
Updates the name/description of a Fabric item.
- Parameters:
item_type (str) – Type of item to update.
current_name (str) – The current name of the item.
new_name (str) – The new name of the item.
description (str, default=None) – A description of the item.
workspace (str, default=None) – The Fabric workspace name. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
- sempy_labs.vertipaq_analyzer(dataset: str, workspace: str | None = None, export: str | None = None, lakehouse_workspace: str | None = None, read_stats_from_data: bool | None = False)
Displays an HTML visualization of the Vertipaq Analyzer statistics from a semantic model.
- Parameters:
dataset (str) – Name of the semantic model.
workspace (str, default=None) – The Fabric workspace name in which the semantic model exists. Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
export (str, default=None) – Specifying ‘zip’ will export the results to a zip file in your lakehouse (which can be imported using the import_vertipaq_analyzer function. Specifying ‘table’ will export the results to delta tables (appended) in your lakehouse. Default value: None.
lakehouse_workspace (str, default=None) – The Fabric workspace used by the lakehouse (for Direct Lake semantic models). Defaults to None which resolves to the workspace of the attached lakehouse or if no lakehouse attached, resolves to the workspace of the notebook.
read_stats_from_data (bool, default=False) – Setting this parameter to true has the function get Column Cardinality and Missing Rows using DAX (Direct Lake semantic models achieve this using a Spark query to the lakehouse).