Copy Power BI data model back to PBIX file

Do you know this message? “This file can’t be downloaded yet. You can’t download this file right now because it’s been modified using an XMLA endpoint.” How to copy the Power BI data model back to a PBIX file anyway, I describe in this post.

This file can't be downloaded yet. You can't download this file right now because it's been modified using an XMLA endpoint.

NOTE: The workaround described here is not officially supported by Microsoft. If you use this workaround, you do so at your own risk.

required tools:

To begin, we create an empty PBIX file by opening the Power BI Desktop and going directly to “File > Save As” to save the file. In this example I call the file “Container.pbix”.

Power BI Desktop save empty PBIX file

Now we extract the PBIX file using pbi-tools and the parameter “-modelSerialization Raw”. The parameter ensures that the model information is not split between directories and files, but is stored in a database.json file (BIM file).

pbi-tools extract '.Container.pbix' -modelSerialization Raw
pbi-tools extract

Using the Tabular Editor, we connect against the XMLA endpoint of our workspace.

Tabular Editor XMLA-Endpunkt

Then select the appropriate data model (database).

Tabular Editor database selection

Via “File > Save as” we now overwrite the database.json file in the “Model” directory of our extracted “Container.pbix” file with the loaded model

Tabular Editor Save data model as dabase.json

Now we compile the container with the integrated data model using pbi-tools.

pbi-tools compile '.Container' '.' PBIT -overwrite
pbi-tools compile

If we now open the compiled PBIT file with Power BI Desktop and perform the file update, we have the data model back in a PBIX file.

That’s it. ?


This file can't be downloaded yet
You can't download this file right now because it uses incremental refresh.

If your data model uses incremental refresh, you will need to do some editing of database.json before compiling.

You must replace the partitions of type “policyRange” with a partition of type “m” with the corresponding “expression”.

Visual Studio Code: Partitionen in database.json

The required “expression” can be found as “sourceExpression” in the corresponding “refreshPloicy” of the query in the database.json file.

Visual Studio Code: "sourceExpression" in the corresponding "refreshPloicy" of the query

Want more cool Power BI content?
Then follow me on LinkedIn and feed your newsfeed with my content:

Marcus Wegener | ​

Veröffentlicht von

Marcus Wegener

Marcus Wegener

Marcus Wegener ist Anwendungsentwickler für Business Intelligence und erstellt Lösungen, mit denen sich große Datenmengen schnell analysieren lassen. Kunden nutzen seine Lösungen, um die Vergangenheit zu analysieren, die Gegenwart zu steuern und die Zukunft zu planen, um damit mehr Erfolg zu generieren. Dabei ist seine einzigartige Kombination aus Wissen und Auffassungsgabe ein Garant für ihren Erfolg.

12 Gedanken zu „Copy Power BI data model back to PBIX file“

      1. Not the OP but I found it through Google. Unfortunately I cannot test it out now because I do not have sufficient rights on my machine. It looks good & is exactly what I’m looking for though!

  1. Hi Marcus

    Nice to see you here :-).
    We are deploying our changes via ALM toolkit to the dataset in pbi service.
    We have deployed a change that consist out of an added table and a relationship. Somehow the local file went missing and we have a previous local version but without the table and relationship. We usually deploying from the pbix to the workspace, but in this matter we want to do it the other way around. ALM detects the difference and it looks like it’s commiting the changes but the pbix file is not updated. Do you know if this scenario is supported? It’s a fully imported model

    Best regards


  2. This is very helpful, thanks. I’ve successfully completed all of these steps except when I try to open the PBIT file it says that it can’t be opened because it is encrypted or corrupted. Any idea what I may be doing wrong?

    1. Hi, I suspect that the data model uses features that are not directly supported by Power BI Desktop, such as multiple partitions.
      You are welcome to provide me with the file, then I will have a look at it.
      Keep me posted if you have solved the problem so we can all learn from it. ?

      There is now an article by Kurt Buhler that describes the same procedure. This way you can double check the individual steps.

  3. Any thoughts on how to accommodate error “The QueryDependencyGraph should not be null for a V3 model” ?

    I am trying to convert old SSAS models, built around 2020 on SSAS 2016, and I keep getting this error when I use the method above, no matter how I tinker with the settings it will not open.

    1. Hi Be,
      Kurt writes in his blog that there are differences in the .bim file for the different AS models.

      ? Limitation 1: Doesn’t work with AAS datasets
      The .bim file from an AAS dataset is not using the Power BI format. For example, the Model.DataSources Property does not exist in the Power BI metadata.

      If the AAS .bim and Power BI dataset .bim were the same, migration would be simple ?
      I would create a simple data model with Power BI and use it as a reference for customizations.

  4. Marc, I have tried to follow the method and everything looks fine. I only bump in the problem that PowerBI keeps saying I have pending changes in my queries. Any idea how to fix this?

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

I accept that my given data and my IP address is sent to a server in the USA only for the purpose of spam prevention through the Akismet program.More information on Akismet and GDPR.