Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Metric sets are collections of metrics and key performance indicators you create and use for greater accuracy, consistency, and reliability in reports and analysis. This guide walks you through methods to effectively use and monitor metrics in Power BI, including integrating metrics into reports, notebooks, and APIs, as well as understanding their lineage and usage.
If you haven't created a metric set yet, see Create and manage metric sets for details.
Use metrics in a report
To use a metric in a report:
In the open metric set, select the Use metric dropdown, then select Use in new report.
A new report canvas opens for editing. Add data sources and build your report solution.
Note
For all report authoring scenarios, connecting to a metric currently brings the entire semantic model into the Data pane. In the future, the Data pane will only show the selected metric and its related dimensions.
Use metrics in notebooks
The metrics layer offers a powerful experience for using data outside of Power BI. You can generate a code snippet from a metric set, copy it, and apply it to use the metric in notebooks or other Python environments.
To use a metric in a notebook:
In the open metric set, select the Use metric dropdown, then select Copy code to notebook.
Copy the code snippet provided in the window that opens.
Navigate to a new or existing notebook.
Paste the code snippet into a cell.
Use groupby additions to include specific dimensions (optional step).
Run the cell and produce a dataframe.
You can save this back to your lakehouse so that the data is accessible outside of Power BI.
Use metrics with APIs
Metric sets are Fabric artifacts, so you can use them with public APIs. While APIs use the metadata in the metric set, the individual metrics that make up the metric set aren't accessible via the public Fabric APIs. For more information, read the Microsoft Fabric REST API documentation.
You can access metric data via API using the semantic link feature and SemPy, a Python library that simplifies working with semantic data. The Use in notebook option on the metric details page gives you a pregenerated code snippet that you can use to access the metric data via API. For more information, read Use metrics in notebooks.
Understand lineage
In Power BI, the lineage view is essential for creators. The lineage view offers visibility into data flow, supports impact analysis, aids in troubleshooting, enforces data governance, optimizes performance, enhances collaboration, and provides documentation. This comprehensive understanding is critical for maintaining the accuracy, efficiency, and effectiveness of data-driven projects.
Metric sets show up in both workspace lineage views and data lineage views:
Workspace lineage view: Focuses on the relationships between items within a specific Power BI workspace, helping users understand how different components are interconnected.
Data lineage view: Provides an end-to-end view of how data is sourced, transformed, and used in reports and dashboards, covering the entire data lifecycle.
There are a couple other ways for creators to understand the lineage and usage of a metric:
Usage section: Users can also utilize the Usage section for a metric set. This section displays a metric's specific downstream applications. For example, if a metric (or its underlying measure) is used in 10 reports, all 10 reports appear in this table.
Semantic model details page: Metric set artifacts show up in the See what already exists table for a semantic model if a metric uses a measure located in that model.