Skip to content
m-kovalsky edited this page Feb 16, 2025 · 11 revisions

Welcome to the semantic-link-labs wiki!

Code examples

Best Practice Analyzer

import sempy_labs as labs

dataset = '' # Enter the name or ID of your semantic model
workspace = None # Enter the name or ID of the workspace in which the semantic model resides

labs.run_model_bpa(dataset=dataset, workspace=workspace)
labs.run_model_bpa(dataset=dataset, workspace=workspace, extended=True)

Vertipaq Analyzer

import sempy_labs as labs

dataset = '' # Enter the name or ID of your semantic model
workspace = None # Enter the name or ID of the workspace in which the semantic model resides

labs.vertipaq_analyzer(dataset=dataset, workspace=workspace)

Connecting to the Tabular Object Model (TOM)

from sempy_labs.tom import connect_semantic_model

dataset = '' # Enter the name or ID of your semantic model
workspace = None # Enter the name or ID of the workspace in which the semantic model resides

with connect_semantic_model(dataset=dataset, workspace=workspace, readonly=True) as tom:
   for t in tom.model.Tables:
       for c in t.Columns:
          print(f"'{t.Name}'[{c.Name}]")

Refresh a semantic model

import sempy_labs as labs

dataset = '' # Enter the name or ID of your semantic model
workspace = None # Enter the name or ID of the workspace in which the semantic model resides

labs.refresh_semantic_model(dataset=dataset, workspace=workspace)
labs.refresh_semantic_model(dataset=dataset, workspace=workspace, tables = ['Sales', 'Geography'])
labs.refresh_semantic_model(dataset=dataset, workspace=workspace, tables = ['Geography', 'Calendar'], partitions = ["'Sales'[SalesFY2025]", "'Sales'[SalesFY2025]")
labs.refresh_semantic_model(dataset=dataset, workspace=workspace, visualize=True)

Show connections

import sempy_labs as labs

labs.list_connections()

Show shortcuts

import sempy_labs as labs

workspace = None # Enter the name or ID of the workspace

labs.list_shortcuts(workspace=workspace)

Show activity events

from sempy_labs import admin

admin.list_activity_events(start_time="2025-02-15T07:55:00", end_time="2025-02-15T08:55:00", activity_filter="viewreport")

Show tenant settings

from sempy_labs import admin

admin.list_tenant_settings()

Show tables within a lakehouse

import sempy_labs.lakehouse as lake

lakehouse = None
workspace = None

lake.get_lakehouse_tables(lakehouse=lakehouse, workspace=workspace)

Show columns within all tables within a lakehouse

import sempy_labs.lakehouse as lake

lakehouse = None
workspace = None

lake.get_lakehouse_columns(lakehouse=lakehouse, workspace=workspace)

Rebind a report to a different semantic model

import sempy_labs.report as rep

report = '' # Name or ID of the report
dataset = '' # Name or ID of the semantic model to bind to the report
report_workspace = None # Name or ID of the workspace in which the report resides
dataset_workspace = None # Name or ID of the workspace in which the semantic model resides

rep.rebind_report(report=report, dataset=dataset, report_workspace=report_workspace, dataset_workspace=dataset_workspace)
Clone this wiki locally