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
25 Feb, 2026

Power Apps Production Deployment Checklist: Best Practices for a Smooth Go-Live

Introduction In Power Apps, even a small mistake during deployment can impact users and business processes. This checklist will help…

READ MORE
PCF Ribbon Button Thumbnail
Blogs
16 Feb, 2026

Launching a PCF Control from a Ribbon Button using Custom Pages in Dynamics 365

Introduction: In Model-driven apps, PCF controls are typically embedded inside forms or views. However, unique business requirements often demand more…

READ MORE
Blogs
20 Jan, 2026

How to Add Dataverse as a Data Source in Power Apps Code Apps

In my previous blog, I explained what Power Apps Code Apps are and how we can build apps using React…

READ MORE