Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Peter_MTG
Frequent Visitor

Powershell : Tabular Object Model, model object is null

I sometimes use PowerShell to quickly alter a set of similar measures in a Power BI dataset. This could be done with this code :

 

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices.Tabular")

$serverName = "localhost:xxxxx";
$databaseName = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
$svr = New-Object Microsoft.AnalysisServices.Tabular.Server
$svr.Connect($serverName)
$db = $svr.databases.GetByName($databaseName)

 

$findstring="find string"
$replacestring="replace string"

foreach($table in $db.Model.Tables) {
  foreach($measureobj in $table.measures) {
  $measureobj.expression=$measureobj.Expression.replace($findstring,$replacestring)
}
}

#$db.Model.SaveChanges()

 

Works great, until recently I found some reports where the Model-attribute of the database seems to be empty.

 

Peter_MTG_0-1685536489428.png

 

 Although it works perfectly fine in PowerBI, I can't find the model anymore in PowerShell. Also Tabular and DAX Studio are working fine with the reports dataset.

1 ACCEPTED SOLUTION
Peter_MTG
Frequent Visitor

I saw that in the report one of the datasources was still using the Power BI dataflows (Legacy) connector. As soon as I switched this one to the Power BI dataflows connector, the model attribute was correctly filled in.

 

I'm not 100 % using this connector always causes this problem, but at least in this case, replacing it solved the issue.

View solution in original post

1 REPLY 1
Peter_MTG
Frequent Visitor

I saw that in the report one of the datasources was still using the Power BI dataflows (Legacy) connector. As soon as I switched this one to the Power BI dataflows connector, the model attribute was correctly filled in.

 

I'm not 100 % using this connector always causes this problem, but at least in this case, replacing it solved the issue.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors