Find duplicate DAX expressions in your Power BI or Fabric tenant
Two approaches to finding duplicate DAX measures across your entire Power BI tenant -- the Scanner API and Measure Killer's automatic duplicate detection.
Getting all DAX expressions across all models and reports in your Power BI tenant can be very useful. This would include measures, report-level measures as well as calculated tables and calculated columns (though this post focuses on measures).
Use Cases
- Ensuring everyone uses the correct definition/calculation of a KPI or measure
- Identifying duplicate expressions so organizations can consolidate to single measures rather than having individuals build their own
Two Available Options
Option 1: WorkspaceInfo API Calls (Scanner API)
Pros
- Free
Cons
- Requires programming skills and JSON parsing
- Time intensive
- Does not include report-level measures
- Requires Fabric Administrator or Power Platform Administrator role
- PostWorkspaceInfo call limited to 100 workspaces per call
Option 2: Measure Killer’s Tenant Analysis
Pros
- Easy to use
- Includes report-level measures
- Finds duplicates automatically (parses whitespace and comments)
- No workspace or model limitations
- Easy export of DAX expressions as .json
- Admin rights optional
Cons
- Part of paid Measure Killer version
- External client application
Option 1 Implementation Details
Requirements
- Fabric Administrator or Power Platform Administrator role
- Two tenant settings enabled: “Enhance admin APIs responses with detailed metadata” and “Enhance admin APIs responses with DAX and mashup expressions”
Python Example (version 3.12.4)
from azure.identity import InteractiveBrowserCredential
import requests
import time
# Replace the following list with the workspaces you want to scan. This is limited to 100 workspaces
workspace_list = [
"workspace_id_1",
"workspace_id_2"
]
# Do not change the following code:
api = "https://analysis.windows.net/powerbi/api/.default"
authority = "https://login.microsoftonline.com/"
auth = InteractiveBrowserCredential(authority=authority)
access_token = auth.get_token(api).token
url="https://api.powerbi.com/v1.0/myorg/admin/workspaces/getInfo?datasetExpressions=true&datasetSchema=true"
payload = {"workspaces": workspace_list}
header = {"Authorization": f"Bearer {access_token}"}
response = requests.post(url, headers=header, json=payload)
wk_post_data=response.json()
scan_id = wk_post_data.get('id') # The scan id, will be passed to the get scan results api call
# Sleeps for 2 seconds to allow the scan to complete
# ! This will probably require a longer sleep time for larger workspaces or checking for the status of the scan using the GetScanStatus API
time.sleep(2)
# Get the actual results
results_url=f"https://api.powerbi.com/v1.0/myorg/admin/workspaces/scanResult/{scan_id}"
results=requests.get(results_url, headers=header)
print(results.json())
Option 2 Implementation Details
Using Measure Killer’s tenant analysis mode, users can scan their entire tenant including all DAX expressions in all models and reports. A dedicated function identifies duplicate DAX expressions across the tenant.
The tool can filter duplicates at either the model level or tenant level. For large tenants with thousands of models, the tenant-level search may take 1-2 minutes or longer.
The duplicate detection strips comments and whitespace when comparing expressions. Results show the expression (for example, SUMX(factData, 1)), measure names, and most importantly, which semantic models contain the duplicates.
This capability provides valuable insights for larger tenants considering KPI convergence initiatives and reveals what report-level measures organizations are building.
Conclusion
Multiple options exist for accessing DAX expressions within a single Power BI model. However, tenant-wide access is more limited. Organizations can leverage REST API programming or Measure Killer’s Tenant Analysis mode for an accessible, ready-to-use experience for extracting all DAX expressions. Both approaches allow extraction of M expressions as well through minor query modifications.