Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi,
I want to detect the current environment (Dev or Prod) inside my Power BI report after it's published to Power BI Report Server.
Each environment has a different Web Portal URL:
Dev Server: http://dev-reportserver/Reports/powerbi/...
Prod Server: http://prod-reportserver/Reports/powerbi/...
I need a way to access the Web Portal URL or server name from within the report, ideally using DAX, so I can dynamically determine which environment the report is running in.
In short, you're trying to dynamically determine the hosting environment of a Power BI report using DAX or other internal logic, based on where it's published.
I would create a table in my source database (one for dev and one or prod), and have a config table to store these settings. Then the table can be part of the model for a DAX column or measure.
Hi @ArwaAldoud,
There isnโt a supported way for a Power BI report on Report Server to read its own Web Portal URL or server name from DAX. DAX has no concept of the hosting URL, and PBIRS doesnโt surface that as a model property. The usual pattern is to bring an โenvironmentโ value in through your data (SQL, M parameter, etc.) and reference it with a simple DAX measure. Microsoft Learn confirms URL-based filtering for PBIRS but not reading the URL inside the report; community threads also note DAX canโt access the browser/URL directly. Example discussion.
Put the environment in your data and read it with DAX.
If your report hits SQL Server, expose a single-row view that returns your environment based on the server youโre connected to. SQL Server provides @@SERVERNAME, which you can map to โDevโ vs โProd.โ (Docs: @@SERVERNAME)
Example SQL view
CREATE VIEW dbo.vEnvironment AS
SELECT
CASE
WHEN @@SERVERNAME LIKE '%DEV%' THEN 'Dev'
WHEN @@SERVERNAME LIKE '%PROD%' THEN 'Prod'
ELSE 'Unknown'
END AS EnvironmentName;Load dbo.vEnvironment (1 row) into your model and create:
DAX
Environment = VAR env = SELECTEDVALUE( vEnvironment[EnvironmentName], "Unknown" ) RETURN env
Use [Environment] in cards/titles/conditional formatting. When the same PBIX points at Dev vs Prod SQL, the measure changes automatically.
If you found this helpful, consider giving some Kudos. If I answered your question or solved your problem, mark this post as the solution.
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |