Forum Discussion
How to create field parameters in Power BI DirectLake Datasets using LIVE connection to Desktop?
Field parameters can be created at the semantic model using notebooks in fabric for live query connections, this might not be the direct approach, but it works.
1. Enable XMLA endpoint property to read-write for your capacity(Semantic model connectivity and management with the XMLA endpoint in Power BI - Power BI | Microsoft Learn)
- Select Settings > Admin Portal
- In Admin Portal select Power BI settings > Power BI Premium > Capacity name
- Expand Workloads. In the XMLA Endpoint setting, select Read Write.
2. Go to app.powerbi.com (make sure your direct lake semantic model is visible in Power BI service) and go to Data Engineering and go to your workspace.
3. To create a notebook, click on new > notebook.
4. Copy and paste the below code to install required package and import necessary modules.
%pip install semantic-link-labs
import sempy
from sempy_labs.tom import connect_semantic_model
5. After the required package and modules are imported hover below the result to add new code cell to the notebook.
6. copy paste the below code in the new cell (with correct indentation) to add field parameter to the semantic model.
datasetName = ‘YourDataSetName’
WorkspaceName = ‘YourWorkspaceName’
With connect_semantic_model(dataset = datasetName, readonly = False, workspace = WorkspaceName) as model:
FieldParameterTable = ‘Name of your field parameter table’
FieldsIncluded =[“’Table1nameInSemanticMode’[column_name]”, ”’Table1nameinsemanticmodel’[Columnname1]” , “’Table2nameInSemanticMode’[column_name2]”]
model.add_filed_parameter(table_name = FieldParameterTable, objects = FieldsIncluded)
Note: Make sure to correct the indentation for above code.
7. Replace
- ‘YourDataSetName’ with your dataset/semantic model name (Example: ‘SalesTerritory’)
- ‘YourWorkspaceName’ with your workspace name
- ‘Name of your field parameter table’ with your new field parameter table name to be created
- [“’Table1nameInSemanticMode’[column_name]” with table name in your semantic model followed by column to be included in filed parameter table
8. execute the cell and refresh your semantic model in power BI service, you will find a new field parameter table created.
If you have any queries/facing issues with implementation, feel free to message me on my LinkedIn
Accept this as solution if it helps you😊