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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Solved! Go to Solution.
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.
We’ve managed to solve this
Since Power BI Report Server doesn’t provide a built-in way to detect the hosting environment (Dev or Prod) through DAX, we created a table in each environment’s database ( Dev DB and Prod DB) that includes:
Report Name | Environment | URL (base path + report path)
Before uploading a report, we switch the data source to the correct environment — for example, Prod when publishing to production, and Dev when working in development.
Then, within the report, I use a measure to dynamically pick the right URLs based on the report name.
It required adding the report URLs manually, but it works.
We’ve managed to solve this
Since Power BI Report Server doesn’t provide a built-in way to detect the hosting environment (Dev or Prod) through DAX, we created a table in each environment’s database ( Dev DB and Prod DB) that includes:
Report Name | Environment | URL (base path + report path)
Before uploading a report, we switch the data source to the correct environment — for example, Prod when publishing to production, and Dev when working in development.
Then, within the report, I use a measure to dynamically pick the right URLs based on the report name.
It required adding the report URLs manually, but it works.
Hi @ArwaAldoud ,
Thank you @tayloramy the response provided!
Has your issue been resolved? If the response provided by the community member addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.
Thank you for your understanding!
Hi @ArwaAldoud ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.
Thank you,
Tejaswi.
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.
Hi @tayloramy
Thanks! We followed a similar approach using a SQL view — but instead of relying on @@SERVERNAME, we maintain a metadata table (report name, environment, and URL)
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.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 2 | |
| 2 | |
| 1 |