Forum Discussion
Use Variable Library in Power BI report / semantic model
I'm trying to define a pattern when developing new items in Fabric.
Configuration:
- Development workspace with a dev branch
- Production workspace with a prod branch
My plan is to use Variable Libraries to change variable values based on the environment.
There is a variable set for each environment:
- DEV variable set is set as active in development workspace
- PROD variable set is set as active in production workspace
This approach works well with pipelines, but I wonder if it's possible to use it with Reports and Semantic Models.
I tried using "web" query to get the data from Azure DevOps JSON files but it's required to provide the branch and I don't want to hardcode the branch name since they are source controlled.
Hi FreddyH,
Variable Libraries in Microsoft Fabric integrate well with Data Pipelines, as pipelines support environment-specific variable sets natively. However, Power BI Reports and Semantic Models currently do not have native support for dynamically using Variable Libraries at runtime like pipelines do.
Reports and semantic models can't automatically change values based on the active workspace variable set. If you try to retrieve variables using a web query (such as Azure DevOps JSON), you'll find that explicit parameters like branch name or endpoint are needed, which can lead to hard-coding unless you externalize these parameters.
One solution is to use Power Query parameters or semantic model parameters and manage their values with deployment pipeline rules. Deployment pipelines let you override parameter values for each stage (Dev/Test/Prod), so you don't have to hard-code branch names in your query. This is the closest supported method for reports and semantic models.
Another approach is to keep configuration in a central table (such as Lakehouse, Warehouse, or a Key Vault-backed source) and let the semantic model read the configuration based on the workspace or environment. This removes branch dependency and keeps configuration external.
While Power BI reports and semantic models can't directly use Variable Libraries yet, you can achieve similar results with parameters and deployment pipeline rules or a central configuration source. If you need more direct integration with Variable Libraries, submitting feedback to the Fabric Ideas forum is recommended, as this feature is not currently available.
Fabric Ideas - Microsoft Fabric CommunityThank you.
6 Replies
- tayloramySuper User
Hi FreddyH,
Variable libraries are not supported in Semantic Models or Reports.
https://learn.microsoft.com/en-us/fabric/cicd/variable-library/variable-library-overview#supported-items - v-sgandrathiCommunity Support
Hi FreddyH,
Variable Libraries in Microsoft Fabric integrate well with Data Pipelines, as pipelines support environment-specific variable sets natively. However, Power BI Reports and Semantic Models currently do not have native support for dynamically using Variable Libraries at runtime like pipelines do.
Reports and semantic models can't automatically change values based on the active workspace variable set. If you try to retrieve variables using a web query (such as Azure DevOps JSON), you'll find that explicit parameters like branch name or endpoint are needed, which can lead to hard-coding unless you externalize these parameters.
One solution is to use Power Query parameters or semantic model parameters and manage their values with deployment pipeline rules. Deployment pipelines let you override parameter values for each stage (Dev/Test/Prod), so you don't have to hard-code branch names in your query. This is the closest supported method for reports and semantic models.
Another approach is to keep configuration in a central table (such as Lakehouse, Warehouse, or a Key Vault-backed source) and let the semantic model read the configuration based on the workspace or environment. This removes branch dependency and keeps configuration external.
While Power BI reports and semantic models can't directly use Variable Libraries yet, you can achieve similar results with parameters and deployment pipeline rules or a central configuration source. If you need more direct integration with Variable Libraries, submitting feedback to the Fabric Ideas forum is recommended, as this feature is not currently available.
Fabric Ideas - Microsoft Fabric CommunityThank you.
- FreddyHAdvocate II
Since I'm trying to implement a CICD method based on PR (documented here), it's not possible to use deployment pipelines for promotion without ending with Semantic Models with different hardcoded values as data sources for each environment, this could cause merging conflicts in the future.
I've created a new idea for that here.
- stoic-harshSuper User
Hey FreddyH,
As tayloramy and v-sgandrathi stated, variable libraries are not supported in SM. If you are only trying to switch connections, you can use Power BI Parameters + Deployment Rules.
Inside Power BI Desktop (or SM), create parameters like LakehouseName, WorkspaceName, ServerEndpoint, etc. Then reference them in Power Query like workspace = WorkspaceName (instead of static value "DevWorkspace") and so on. Publish the model and create Deployment Pipeline rules to modify the connection binding of the semantic model during promotion.
This way fabric automatically rewrites the connection. No branch name, no JSON, no web queries.
- FreddyHAdvocate II
I've created a new Idea to provide support to Semantic Models in Variable Library here.
Since I'm trying to implement PR base promotion (documented by MS here), it's not possible to use Deployment Pipelines to update data sources on the fly without ending with hardcoded values that could generate merging conflicts in the future.
- v-sgandrathiCommunity Support
Hi FreddyH,
That makes sense, in a PR-based promotion workflow, using Deployment Pipeline rules to rewrite parameters can add environment-specific values to the semantic model metadata, increasing the risk of merge conflicts between branches. Since Variable Libraries aren't currently available for Semantic Models, changing data source values during promotion isn't always suitable for PR-driven CI/CD processes.
In these cases, it's more reliable to keep environment configuration outside the semantic model, rather than embedding or rewriting values within the model definition. You can do this by storing connection and environment settings in a central configuration source, like a Lakehouse or Warehouse table, a config file, or a Key Vault-backed endpoint, while keeping the semantic model parameterized with just a minimal identifier such as the Environment name.
By resolving connection details dynamically at refresh time from the external configuration source, you can move the same model artifact across environments without hard-coded changes, reducing merge conflicts and keeping the PR workflow clean. Your Idea submission is timely, as native Variable Library support for Semantic Models would help address this challenge and make PR-based promotion easier.
Thank you.