The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
08-05-2025 07:03 AM - last edited 08-05-2025 07:04 AM
Visual calculations in Power BI are a powerful new feature that allows you to create custom measures directly within a visual, without modifying the underlying data model. They offer a more intuitive way to build calculations by referencing existing fields and measures already present in a visual, making it easier to experiment and iterate quickly.
Unlike traditional DAX measures defined at the model level, visual calculations are scoped to the visual in which they are created. This gives report authors greater flexibility, reduces model complexity, and enables advanced scenarios such as ranking, moving averages, and dynamic calculations based on the visual's context — all without needing to write complex DAX upfront.
Whether you're building quick insights or experimenting with advanced logic, visual calculations help you stay focused on the analysis, directly where it matters most: the visual itself.
From a governance, compliance, and administration standpoint, it’s crucial to understand and monitor how visual calculations are used across your organization. Maintaining a single source of truth is a cornerstone of effective data governance. When users create visual calculations outside the centralized semantic model, it can lead to inconsistent metrics, conflicting report outcomes, and ultimately, reduced trust in the data. As administrator, you may think just blocking the use of Visual Calculations could be the desired solution (which is not even possible by the way). However, I'm personally opinionated that blocking will not help, as users will always find a way to achieve their goals. Therefore, I always say: "Better allow in a controlled manner, then block in an uncontrolled manner."
To mitigate these risks, organizations must focus on discovering, managing, and documenting visual calculations as part of their broader governance strategy.
One of the options to discover visual calculations in the Power BI Service, could be using Microsoft Fabric notebooks allow for a code-based integration with any objects that are available in the Power BI Service. Semantic link, a python package in Fabric notebooks, bridges the gap between the code-first world of notebooks and the low-code experience of Power BI by enabling interaction with semantic models as well as functionalities to read report metadata. With semantic link, users can query, analyze, and manipulate semantic models and reports directly from notebooks.
Semantic link labs is an experimental extension of the core Semantic Link package, created to explore and test new features and capabilities built on top of Semantic Link. It provides early access to prototype functions that enhance how developers interact with semantic models, helping shape the future of data-driven development in Microsoft Fabric.
Many of the functions in Semantic Link Labs serve as wrappers around existing APIs, offering a more streamlined and notebook-friendly experience. Both Semantic Link and the Labs extension are exclusively available within Microsoft Fabric notebooks, they are not supported on other platforms.
Before diving into how to find visual calculations using Semantic Link Labs in a notebook, it's important to understand that these expressions are stored as NativeVisualCalculation objects within the report metadata—not in the semantic model like regular measures or calculated columns.
The notebook begins by specifying the report and workspace you want to analyze. It uses the ReportWrapper to load the full report definition, which includes layout details, visual configurations, and internal settings all returned in Base64-encoded format. The notebook decodes this to access the raw JSON structure of the report. Since visual calculations aren’t part of the model metadata, they can’t be queried directly. Instead, the notebook scans the entire report definition to locate any NativeVisualCalculation objects. These can be buried deep in nested JSON structures or hidden within escaped strings in the visual configurations.
Once found, the notebook extracts key details—such as the name, expression language (typically DAX), and the formula itself—and compiles them into a dataframe for easier viewing. This output can be valuable for documentation, governance, or simply gaining better insight into how visual calculations are being used across your reports—something that’s otherwise hard to uncover.
As the Notebook is pretty complex in setup, I did not include the code in this post, but rather link to the GitHub page where the notebook is shared. Any future updates can also be found there.
https%3A%2F%2Fgithub.com%2Fmarclelijveld%2FFabric-Automation%2Fblob%2Fmain%2FSemantic%2520Link%2FExtract%2520Visual%2520Calculations%2520Definitions%2FNB_EXRCT_VisualCalculationsDefinitions.ipynb