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.
Hello,
How to change lakehouse connected to semantic model?
So imagine I can have 2 situations:
1. Semantic Model on OneLake flavour connected to lakehouse1
What if i have second lakehouse2 and want to switch current semantic model to it? Assuming that i have the same tables like in old Lakehouse1 plus some news?
2. How can i have a "Baseline" lakehouse and connect to it each time when I am creating a new semantic model and connect to some custome specific lakehouse to use different table? How to make this manually and in programmatic way?
How to make those steps both manually and programmaticaly?
Best,
Jacek
Solved! Go to Solution.
Hi @jaryszek ,
The error appears because parameters can only be declared at the model level, not inside tables or partitions. Here’s how to do it correctly.
Correct Syntax
In your model.tmdl, define the parameters like this:
model "SalesModel" {
parameter LakehouseName = "SalesLakehouse"
parameter WorkspaceId = "abc123xyz"
culture = "en-US"
annotations = []
}
Once defined, you can reference those parameters in your table or partition definitions, for example:
table "SalesTable" {
partition "DirectLake" {
mode = "DirectLake"
expression =
let
Source = AzureStorage.DataLake(
$"https://onelake.dfs.fabric.microsoft.com/{WorkspaceId}/{LakehouseName}",
[HierarchicalNavigation = true]
)
in
Source
}
}
This will works for you. If you try to place parameter inside a table or partition block, you’ll get. The keyword 'parameter' is neither a property nor an object in the current context. That’s because TMDL only recognizes parameters when they’re declared at the model scope.
Keep reusable values like LakehouseName and WorkspaceId in the model file and reference them using $"{WorkspaceId}/{LakehouseName}" it makes your model cleaner and easier to maintain.
Thanks,
Akhil.
Hi @jaryszek ,
The error appears because parameters can only be declared at the model level, not inside tables or partitions. Here’s how to do it correctly.
Correct Syntax
In your model.tmdl, define the parameters like this:
model "SalesModel" {
parameter LakehouseName = "SalesLakehouse"
parameter WorkspaceId = "abc123xyz"
culture = "en-US"
annotations = []
}
Once defined, you can reference those parameters in your table or partition definitions, for example:
table "SalesTable" {
partition "DirectLake" {
mode = "DirectLake"
expression =
let
Source = AzureStorage.DataLake(
$"https://onelake.dfs.fabric.microsoft.com/{WorkspaceId}/{LakehouseName}",
[HierarchicalNavigation = true]
)
in
Source
}
}
This will works for you. If you try to place parameter inside a table or partition block, you’ll get. The keyword 'parameter' is neither a property nor an object in the current context. That’s because TMDL only recognizes parameters when they’re declared at the model scope.
Keep reusable values like LakehouseName and WorkspaceId in the model file and reference them using $"{WorkspaceId}/{LakehouseName}" it makes your model cleaner and easier to maintain.
Thanks,
Akhil.
thank you!
Hi @jaryszek ,
You're absolutely right, it’s not M code. When working with Power BI Studio (VS Code) and TMDL (Tabular Model Definition Language), you're scripting the semantic model directly, not using Power Query. Here's how to approach parameterizing Lakehouse connections.
1. Enable TMDL View in Power BI Desktop (Preview)
2. Define Parameters in TMDL.
parameter LakehouseName = "SalesLakehouse"
parameter WorkspaceId = "abc123xyz"
3. Use Parameters in Data Source.
expression 'SalesTable' = let Source = AzureStorage.DataLake( $"https://onelake.dfs.fabric.microsoft.com/{WorkspaceId}/{LakehouseName}", [HierarchicalNavigation = true] ) in Source
4.Deploy with Updated Parameters
Use Tabular Model Definition Language (TMDL) view in Power BI Desktop - Power BI | Microsoft Learn
Solved: Re: Data Source Parameters in Direct Lake mode - Microsoft Fabric Community
Thanks,
Akhil.
wow this is a gold!
I tried to add parameters like here:
but it is showing error:
TMDL Format Error: Parsing error type - UnknownKeyword Detailed error - The keyword 'parameter' is neither a property nor an object in the current context! Document - '' Line Number - 3 Line - ' parameter LakehouseName = "SalesLakehouse",'
Why? Where to put them?
Best,
Jacek
Hi @jaryszek ,
Ah, great follow-up, and that error makes perfect sense. In TMDL, parameters must be declared in the correct context. You can't just drop parameter declarations anywhere in the model file. Here's how to fix it.
Correct Way to Declare Parameters in TMDL.
Parameters should be placed inside the model.tmdl file, not in a table or partition definition. Think of model.tmdl as the root configuration file for your semantic model.
model "SalesModel" { parameter LakehouseName = "SalesLakehouse" parameter WorkspaceId = "abc123xyz" culture = "en-US" annotations = [] }
Then, in your table or partition .tmdl files, you can reference these parameters like this.
table "SalesTable" { partition "DirectLake" { mode = "DirectLake" expression = let Source = AzureStorage.DataLake( $"https://onelake.dfs.fabric.microsoft.com/{WorkspaceId}/{LakehouseName}", [HierarchicalNavigation = true] ) in Source } }
Made Common Mistake by placing parameter inside a table or partition block will trigger the exact error you're seeing.
The keyword 'parameter' is neither a property nor an object in the current context.
Thanks,
Akhil.
ok thank you.
but still has issue:
I have open tmdl model like here.
And trying to add parameters, can I add this from power bi tmdl tab level?
Or i need to save this using Tabular Editor and add there?
Best,
Jacek
Hi @jaryszek ,
You can’t do it directly in Fabric or Tabular Editor. The only way to rebind an existing report (keeping its ID, subscriptions, etc.) is via Power BI REST API specifically the Rebind Report In Group endpoint.
Use Power BI Studio (VS Code) with TMDL. Define parameters like LakehouseName and WorkspaceId, then plug them into your data source. Update the values and redeploy to switch sources.
Open Tabular Editor, go to the table’s partition, and edit the Lakehouse connection details (workspace ID + lakehouse name). Save and deploy.
That’s the cleanest way to do it REST API for rebinding, Power BI Studio for parameterization, Tabular Editor for table-level tweaks.
Thanks,
Akhil.
thanks.
Do you have any tutorials how to parametrize connection in power bi studio?
It will be not M code I assume?
Best,
Jacek
Hi @jaryszek ,
You can handle this in two ways
Switch semantic model from Lakehouse1 to Lakehouse2
Baseline lakehouse + custom overrides
Always check schema compatibility and rebind reports after the switch. Tools like Semantic Link / SemPy or XMLA scripts help automate this.
Thanks,
Akhil.
ok thanks.
"Manual: Create a new semantic model pointing to Lakehouse2, add tables, then rebind reports to it."
How to rebind report manually? From what i know you can use rest apis to do this but this is not manual way...By manual I mean doing this in fabric or Tabular Editor?
Use a template model with parameterized connection info and deploy via script (TMSL/REST API).
"Use a template model with parameterized connection info and deploy via script (TMSL/REST API)."
How to paremetrize connection via rest api and update source tables lakehouse?
And additional question:
How to change data source lakehouse for specific table manually using Direct Lake over OneLake?
Best,
Jacek
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
User | Count |
---|---|
3 | |
2 | |
2 | |
1 | |
1 |