You are opening your .pbix file and an "Unexpected Error" is poping-up, your report is blank. You copy the error message in the clipboard to have a look and you have found out the message Cannot read property 'length' of undefined. Is all your work gone and do you have to do everything again? No you don't, let me show you how to recover your application.
To process this recovering, you need to understand and be able to edit JSON files.
- The error messages
- Recovering your .pbix
1. The error messages
1.1. The original error message
You open your .pbix file into Power BI Desktop and you have this message.
When copy the details into clipboard and paste it somewhere else.
TypeError: Cannot read property 'length' of undefined
If you have exactly this, go to Recovering your .pbix to recovering it.
1.2. The error message while recovering your .pbix
While Recovering your .pbix, you are going to edit json inside the .pbix file itself. If you make a syntax error while editing your .pbix (like a missing comma), the popin is going to be similar, but the error message is different. You are going to have TypeError: Cannot read property 'config' of undefined.
In that case, check your Layout file, and make sure it don't have syntax error.
2. Recovering your .pbix
2.1. Unzip your .pbix
Rename your file into .zip file, example:
MyFile.pbix = MyFile.zip
Open and extract it. Your are going to have the following files:
2.2. Edit Layout.json file
Into the Report folder, you are going to find Layout file. Edit this file with your favorite IDE.
In this JSON file we need to identify the property 'Sections'. All our pages and charts are referenced into this property tag.
Sections is an array which containing our report pages
And report pages is containing an array with our charts. First, we need to identiy under which pages we have the issue.
The idea is to remove one page from the report then Zip and test it until our error dissapear.
Like this, the last page you have removed before your report is back to life (open without error) is the one which containing the error.
Always check the error message, if you have Canno't read "Config" of undefined, it means you have a syntax error into the JSON you have just edited.
Now you know on which page you have the issue. On this page we need to do the same with every charts into your report to remove the corrupted one.
All the charts are into the visualContainers property. It is an array which contains JSON Objects representing your charts.
Remove all charts, reinsert it one by one (be carefull, some charts are children from other chart, check ParentGroupName into config property). Zip and test it until our error dissapear.
That's it, you have removed corrupted chart.
2.3. Zip and test it
Once you have edited your Layout JSON file, you just need to zip all documents then change the extension from .zip to .pbix.