Forum Discussion
Modifying the Layout files to add new visuals or update properties
Hi everyone,
As we know pbix file is collection of different folders which includes the following:
And inside the report folder we have the 'Layout' file (which is a type of JSON file) , the structure is something like (the below Layout file represents a Power BI Report that has two pages and three visuals which include a bar chart, pie chart and a card)
Power BI Report
So I was experimenting whether we can add few visuals from the layout file or modify few attributes of the existing visual (like the fields, or visual aspects like the position, height, width, etc). So I did try the following steps:
1. Created a backup of my test report and then converted the pbix file to a zip (by renaming the extension from '.pbix' to '.zip')
2. Then inside te zip file modified one of the visual aspect of the card on page-2 (height and width)
(Before modifying the height and width the original structure of the card visual)
(To cross check did check in the Power BI report)
So now I modified the value (height and width)
3. Once the changes were made I saved it (to cross check reopened the file the changes were not save even after I overwritten it; So I had to save the modification and save the file as Layout and replace the original one with new one)
4. Then converted the zip back to pbix (even tried with '.pbit') and tried re-opening the report but got
And when I checked for some reasons for this issue (one of them was invalid json structure but before savig the same I had also verified the JSON structure on an online tool and it was fine)
So now I had few questions:
i)That can we update the structure of an existing report by modifying the Layout file.
ii) Is it possible to create a new report if we have the JSON structure: If Yes what are the main components (i.e. mandatory components and which are optional) is there any documentation that can help me in this case
{I did check on Microsoft Co-Pilot about the mandatory components and optional}
- Mandatory Components: Each visual in the visualContainers array must have certain mandatory components:
- config: This contains the visual configuration, including the visual type and data projections.
- dataTransforms: This includes the data transformations applied to the visual.
- query: This defines the data query for the visual.
- position: This specifies the visual's position and size on the report canvas.
- Optional Components: Some components are optional but can be included for additional customization:
- filters: This can be used to apply specific filters to the visual.
- tabOrder: This defines the tab order for keyboard navigation.
So if anyone has any ideas or work-arounds please let me know (as I was trying to accelerate report creation process through code assuming we have a valid JSON structure)
This changes are not supported with pbix or bpit format. They are support with power BI projects. Save your file as pbip and you'll have access to the the report.json file which you can modify. The files should have a JSON schema, so you open with Vs code, you should get a indication of what is valid
10 Replies
- Deku
Super User
This changes are not supported with pbix or bpit format. They are support with power BI projects. Save your file as pbip and you'll have access to the the report.json file which you can modify. The files should have a JSON schema, so you open with Vs code, you should get a indication of what is valid
- Sidhant
Advocate V
Hi Deku ,
Thanks for the guiding to save the file as pbip instead of pbix, after doing this I got the following structure:Inside the 'Report_Name.Report' folder I got the 'json' file (which you mentioned 'Report.json') which was editable in my editor (VS code)
So I tried modifying the height and width of the card visual on Page-2
(Changed the height and width in the json file-> Saved it), I was expecting the height and width to be updated but the changes weren't reflected.
(Changes not reflected)
Right now I am trying to modifying the existing visuals but if I want to a new visual (lets a donut chart or a table visual) then how should I start the construction is can you help me with this (is there any article or documentation that can help to add a new visual in a report through json file).
Regards,
Sidhant.- Deku
Super User
The changes are only seen if you re open the report. Live changes are not supported yet
Can't see any examples online from a quick browse. It is possible. I would turn on git and commit your report. Create a new donut chart or table and look at the git diff to see what changes are applied to your file