Forum Discussion
Can you update a parameter using xmla endpoint and c#?
I am currently using xmla endpoint and c# to dynamically create a semantic model. I am taking a shortcut and creating the model with xmla and then modifying it with code. However, I can't find any examples as to how I can modify a parameter.
I have a parameter named "ClientIDs" and would like to be able to add or remove client id's from that parameter without having to delete the semantic model and recreating it.
I haven't found any examples yet so I don't have any code to post for editing, adding or removing parameters
2 Replies
- AnonymousNot applicable
Hi Don-Bot ,
Please review the following links, hope they can help you.
Deploy and manage datasets using the XMLA endpoint
Power BI Meets Programmability – TOM, XMLA, and C# – SQLServerCentral
Programming Power BI semantic models with the Tabular Object Model (TOM) | Microsoft Learn
// Connect to the semantic model using the XMLA endpoint var connectionString = "DataSource=powerbi://api.powerbi.com/v1.0/myorg/[Workspace];"; var server = new Server(); server.Connect(connectionString); // Get the model var database = server.Databases["YourDatabaseName"]; var model = database.Model; // Add a new parameter var parameter = new Parameter { Name = "ClientIDs", DataType = DataType.String, DefaultValue = "123,456,789" // Set your initial values }; model.Parameters.Add(parameter); // Remove a client ID from the parameter parameter.DefaultValue = "123,789"; // Update the value // Commit the changes model.SaveChanges();Best Regards
- AnonymousNot applicable
Hi Anonymous
There is no such Parameter property for "model".Can you help me on this with an alternative.
Don-Bot , Were you able to find an solution for this?If found please let me know so that it will be helpful for us too.
Thank you:)