-
Notifications
You must be signed in to change notification settings - Fork 411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't open .pbit file with Field Parameters in it #167
Comments
Hi Andrei, sorry for the delayed response. I've tracked down the cause and investigating how to work around it. I'll update when I have progress. |
Hi Andrei, latest release 5.0.33 should be fixed. Please let me know if it worked for you. |
Hi Christian, |
Sounds good Andrei! I did some basic testing and AFAIK it's working. |
Hello Christian, I added a minimalistic sample model where the .pbit file works, but not the .bim file (extracted with tabular editor 2). Removing the relatedColumnDetails attribute from the .bim file, makes it possible again to load the file. |
I can confirm that it works now with .pbit files but the issue is still there if you use .bim file. |
Hi all, thanks for letting me know about this. I have it on the todo list to look at for next release. Just need to get to it as been maxed, but I won't forget it ... |
@christianwade I believe I'm facing a similar issue with Tabular Editor. We need to explicitly specify Since users of Tabular Editor might also save a Power BI model as a .bim file or a folder structure, it might be a bit more complex than just looking at the file extension. We'd have to iterate through the JSON to detect if the TOM includes any objects/properties that are Power BI only, such as |
Thanks Daniel! I'll start a thread and copy you in. And of course, I'm open to code reuse 😀 |
An easy "fix" would be to always invoke the deserializer with |
For Tabular Editor, always deserializing with "CompatibilityModel.PowerBI" is not desirable, as that would cause TOM properties to appear in the UI, which might not be supported on the SSAS/AAS instance that is the intended destination of the model. Instead, I now scan the JSON of the model before deserializing, to detect if any PBI specific properties are present, and set the CompatibilityMode flag accordingly. This is the commit. These are the relevant bits: // If any of the following properties are present in the model, the JSON must be deserialized with CompatibilityMode = PowerBi:
public static readonly HashSet<string> PbiOnlyProperties = new string[] {
"Sets", // Pbi: 1400, Box: Unsupported
"RelatedColumnDetails", // Pbi: 1400, Box: Unsupported
"PerspectiveSets", // Pbi: 1400, Box: Unsupported
}.ToHashSet(StringComparer.OrdinalIgnoreCase);
private static readonly int[] analysisServicesStandardCompatLevels = new[]
{
1200,
1400,
1500,
1600
};
private static bool IsPbiCompatibilityMode(string tomJson)
{
// Use PBI CompatibilityMode when model is one of the non-standard CL's, or if V3 metadata is enabled,
// or if the model is using any PBI-specific TOM properties:
using (var reader = new JsonTextReader(new StringReader(tomJson)))
{
while (reader.Read())
{
if (reader.TokenType == JsonToken.PropertyName)
{
switch ((string)reader.Value)
{
case "compatibilityLevel":
reader.Read();
if (!analysisServicesStandardCompatLevels.Contains((int)((long)reader.Value))) return true;
break;
case "defaultPowerBIDataSourceVersion":
reader.Read();
if ((string)reader.Value == "powerBI_V3") return true;
break;
default:
if (PbiOnlyProperties.Contains((string)reader.Value)) return true;
break;
}
}
}
}
return false;
} And then when deserializing: var mode = IsPbiCompatibilityMode(json)
? Microsoft.AnalysisServices.CompatibilityMode.PowerBI
: Microsoft.AnalysisServices.CompatibilityMode.AnalysisServices;
var database = TOM.JsonSerializer.DeserializeDatabase(json, mode: mode); |
Thanks Daniel. |
Hello Christian, |
You're welcome! |
Hello,
Currently it is impossible to open a data model file (pbit and tabular editor file) with Field Parameters in it. Every attemp of opening a file ends with error message saying "Can't load a file".
The text was updated successfully, but these errors were encountered: