Product December 11, 2024 · 6 min read

New ways to move report-level measures into a semantic model in Power BI

Copy all report-level measures from live connected reports into your semantic model using Measure Killer, and prevent visuals from breaking in the process.

Gregor Brunner Gregor Brunner
New ways to move report-level measures into a semantic model in Power BI

So far there has been no great solution for moving report-level measures (RLMs) from one or multiple live connected reports into a semantic model.

With the new version of Measure Killer (v2.5 or later) you can copy all RLMs from all your thin reports into your semantic model in Power BI in an easy way.

UPDATE (Jan 2025): Go to the bottom of this post to find out how to avoid visuals breaking down after replacing the measures.

Two Options Available

1) Measure Killer Free

Requirements:

  • The dataset file needs to be open in Power BI Desktop
  • All live connected reports need to be downloaded (on my machine)

2) Measure Killer Enterprise (Power BI Service)

Requirement: A Measure Killer license only.

The semantic model and all reports can remain in the Power BI Service.

Request a free trial


Option 1 - Free Version

Step 1: Run Mode 2

Measure Killer v2.5 user interface

Select the semantic model (it pre-selects the file you have open).

Model selection window

Click Next.

Add pages dialog

To “add the pages of the semantic model” is not related to the measures so whatever you click here is fine. This just checks in the general analysis if a measure or column might be used in any report pages of your semantic model.

Step 2: Add Reports

The main window will now open. Here you can drag and drop your thin (live connection) reports from the Power BI Service or click on “Add reports” to select them.

Measure Killer mode 2 main window

Once added, click on Run at the top left.

Measure Killer mode 2 report selection

The standard Measure Killer analysis will display which measures and columns are used and where they are used.


Option 2 - Enterprise Version

Step 1: Run Online Mode

Run mode “Share model online” either as developer or as tenant-admin if you have these permissions.

Measure Killer Enterprise UI showing online modes

We will run the developer version as an example.

Step 2: Authenticate

A window will pop up to trigger you to authenticate with your Power BI / Microsoft account.

Authentication window

Click on the account you want to authenticate with.

Step 3: Select Workspace and Model

Measure Killer workspace and model selection

Click on a workspace and then select the semantic model you want to analyze, then click next.

A new window will pop up showing the workspace where connected thin (live connection) reports were found.

Workspace selection for connected reports

Step 4: Select Connected Reports

The main window will show all connected reports it found. You need to have at least Viewer permissions in a workspace so Measure Killer can find a report connected to your model. If you do not have workspace-level permissions you can always download the .pbix/.pbip files and add them manually using “Add local files” or drag and drop.

Measure Killer online mode showing model lineage

You can unselect reports if you do not care about them and their report-level measures. Once you are happy with the selection, click on Run at the top left.

You may have to authenticate again for the XMLA connection.

Step 5: Run Analysis

Measure Killer will get all the metadata for the model and reports you selected and then run its analysis, which usually takes a few seconds.

Once done, the main window should be visible with all the output. Go to the DAX expressions tab next.

Measure Killer main output window


General Part (Both Options)

Viewing DAX Expressions

Open the DAX expressions tab to see report-level measures with their expressions when expanded.

DAX expressions window of Measure Killer

The DEFINE statement that Measure Killer will generate will look like:

DEFINE
MEASURE '_Measures'[_AverageAge_copy] = 2023 - AVERAGE( people[birthYear] )
MEASURE 'ratings'[Measure 2_copy] = MAX( ratings[tconst] )

Adding Measures to the Semantic Model

Run this code in the browser by opening the semantic model in the Power BI Service and clicking on “Write DAX queries”.

Write DAX queries button in Power BI Service

Enabling editing models in the Power BI Service

If the “Write DAX queries” button is greyed out, make sure your workspace admin turns on the setting shown above.

Paste the code from Measure Killer into the query view.

Inserting report-level measures into a semantic model via DAX query view

Click on “Update model with changes” so the measures will be added to your semantic model.


UPDATE: Jan 2025 - Preventing Visuals from Breaking

The issue until now was that all visuals would break and you would have to manually put model measures into the visuals’ axis or whatever to fix everything.

There is a way to do this quickly using the Enhanced Report Layout (.pbir). This is a preview feature that you need to turn on in Power BI Desktop and you have to save your thin reports as a Power BI project (.pbip) for this to work.

Step 1: Prepare Local Files

Open the .pbip report folder in any text editor like Visual Studio Code or even Notepad.

PBIP folder structure

You need to have all the folders of your thin reports (live connection) on your machine. We also need to have the update to our semantic model ready (from the DAX query view step above).

As soon as we add the report-level measures to the semantic model, our reports will break so we have to keep the downtime to a minimum. Follow this guide step by step.

Step 2: Modify Local Reports

We need to change the code in two areas:

1) Remove the reportExtensions.json (in the definition folder)

You can do this if you want to take out all report-level measures. If you only want to remove part of them, make sure to adjust the .json file accordingly.

2) Go into definition > pages > visuals folder and adjust each visual’s .json file

For each visual that will be affected, we need to adjust that visual’s .json file.

PBIR hierarchy shown in Visual Studio Code

To find out which visuals will be affected, use Measure Killer. Run the tool to see where all report-level measures are used.

Checking which visual.json files we need to adjust via Measure Killer

For example, if you only need to adjust the table and pivotTable (matrix) on page 1 because those are the only places your report-level measures are used, open those files.

Remove every measure where it says "Schema": "extension".

Showing all code snippets that need to be removed from every visual .json

Use find and replace all to replace it with nothing, then save your changes.

Step 3: Add Report-Level Measures to the Model

Add the report-level measures to the model using the DAX query view method described earlier.

As soon as you do this, your thin reports in the Power BI Service will break down, so make sure you can quickly do steps 4 and 5 after that.

Step 4: Open Local Report Files

Open your local thin reports where you changed the code. They should all open correctly without any visuals breaking.

The affected visuals of the reports in the Power BI Service at this point are broken though, so we need to re-publish the local files (those have the code changes applied) as soon as possible.

Error message for report in the Power BI Service where visuals break

Local thin Power BI report file where visual.json properties are already fixed

Step 5: Publish Updated Reports

Publish the local Power BI files (thin reports) where you made your changes and all reports in the Power BI Service will be fixed.