knowledgecenter-breadcrum

Knowledge Center

27 Feb, 2026

How to Use Parameters in Power BI to Connect to Microsoft Dataverse

Posted on 27 Feb, 2026 by Trupti Nikumbh, Posted in Power BI

Blogs

When working with multiple environments in Microsoft Dataverse (DEV, TEST, PROD), hardcoding the environment URL inside Power BI Desktop creates maintenance challenges.

If you move your report between environments, you would normally need to:

  • Edit the connection manually

  • Update credentials

  • Republish the file

But there’s a better way.

In this guide, you’ll learn how to use Parameters in Power BI to dynamically control your Dataverse connection.

Step 1 – Connect to Dataverse Normally (Initial Setup)

First, connect to Dataverse in the usual way.

Open Power BI Desktop.

Go to:

Home → Get Data → Dataverse

Enter your environment URL (example DEV):

 

https://devorg.crm.dynamics.com

Select your required table and click Load.

This creates the initial connection using a hardcoded URL.
 

Step 2 – Open Power Query Editor

Home → Transform Data

This opens the Power Query Editor where we will configure the parameter.


 

Step 3 – Create the Environment Parameter

Inside Power Query:

Home → Manage Parameters → New Parameter

Configure the parameter as follows:

 

Field Value
Name EnvironmentURL
Type Text
Suggested Values Any Value
Current Value https://devorg.crm.dynamics.

Click OK.

This parameter now stores your environment URL dynamically.


 

Step 4 – Replace Hardcoded URL in M Code

This is the most important part.

Select your Dataverse query.

Click:

Advanced Editor

You will see something like:

Source = CommonDataService.Database("https://devorg.crm.dynamics.com")

Replace it with:

Source = CommonDataService.Database(EnvironmentURL)

Important:

  • Remove quotation marks

  • Use the parameter name directly

Click Done.

Now your connection depends on the parameter value.



 

Step 5 – Apply Changes

Close & Apply

Your report now runs using the parameter instead of a fixed URL.

Step 6 – Publish to Power BI Workspace

Home → Publish

Choose your workspace in Power BI Service.

Step 7 – Configure Parameter in Power BI Service

Now go to:

app.powerbi.com → Workspace → Dataset → Settings

Scroll to the Parameters section.

You will see:

EnvironmentURL = https://devorg.crm.dynamics.com

Here you can change the value to:

https://prodorg.crm.dynamics.com

Click Apply.

This updates the dataset to use the new environment.


 

Step 9 – Refresh the Dataset

Click:

Refresh Now

Your dataset will now connect to the new Dataverse environment.

 

How It Works Behind the Scenes

Your M code contains:

CommonDataService.Database(EnvironmentURL)

During refresh:

Power BI replaces EnvironmentURL with the value stored in:

Dataset Settings → Parameters

That is how one PBIX file works across multiple environments.

 

Real Enterprise Deployment Scenario

Environment Parameter Value
DEV https://dev.crm.dynamics.com
TEST https://test.crm.dynamics.com
PROD https://prod.crm.dynamics.com

You publish once.

Then simply change the parameter value in Workspace.

Comment

This is a Required Field

Loading

Recent Updates

Blogs
31 Mar, 2026

Debugging Power Pages Server Logic Using Visual Studio Code

Power Pages Server Logic allows developers to execute secure backend JavaScript directly within Power Pages. It is commonly used for…

READ MORE
Blogs
31 Mar, 2026

Create and Deploy a Single Page Application (SPA) in Power Pages

In this blog, we’ll build and deploy a Single Page Application (SPA) using React + Vite and host it on…

READ MORE
BuildAndDeployPCF_Thumbnail.png
Blogs
25 Mar, 2026

Build And Deploy Your First Dataset PCF Control In Dynamics 365

Introduction In Dynamics 365, subgrids are commonly used to display related records, such as Opportunities under an Account. While out-of-the-box…

READ MORE