m-kovalsky / Tabular

Useful code for tabular modeling and automation.
MIT License
156 stars 61 forks source link

Is there a way to create parameters/shared expression? #12

Closed pawarbi closed 2 years ago

pawarbi commented 2 years ago

Hi Michael - thanks so much for your scripts. I use several of them and save me a lot of time and efforts.

Is there a way to create parameters in TE using scripts? I was able to create Shared expression but couldn't figure out how to set the kind to M and add Expression via script.

Thanks

m-kovalsky commented 2 years ago

You can use this as an example. Also, you can use this documentation as a reference:

https://docs.microsoft.com/dotnet/api/microsoft.analysisservices.tabular.namedexpression.kind?view=analysisservices-dotnet

Model.AddExpression("hello");
Model.Expressions["hello"].Kind = ExpressionKind.M;