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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
edwardlee4948
Frequent Visitor

Help with Python Library for Manipulating Power BI PBIR(report.json) and DIM files

I am trying to build a Python library that can read PBIR and DIM files, specifically for manipulating Power BI reports. I noticed that those are all json format. My goal is to easily copy visuals from one report to another using Python code.

I haven't come across any open-source libraries for this purpose yet. Additionally, I'm finding it difficult to understand the visual configuration files and the various options for Power BI's default visuals (e.g., bar, grid, etc.). I’m wondering if there is a schema available that I could use to convert these configurations into a generic Pydantic dataclass.

I work at a Microsoft partner company, and we need to streamline the process of building Power BI reports quickly. If I've missed any articles or resources related to this topic, please feel free to point me to them.

Thank you!

 

""" example of what I am thinking

platform_content = create_platform(self.report_name)
with open(os.path.join(self.output_path, ".platform"), "w") as f:
f.write(platform_content)
report_config_content = create_report_config()
definition_content = create_definition(self.model_path)
with open(os.path.join(self.output_path, "definition.pbir"), "w") as f:
f.write(definition_content)
report_content = create_report(report_config_content)
self.report = Report(**json.loads(report_content))
report_content = self.report.to_json()
with open(os.path.join(self.output_path, "report.json"), "w") as f:
f.write(report_content)
theme_content = create_theme()
theme_path = os.path.join(self.output_path, THEME_DIR, "CY24SU02.json")
os.makedirs(os.path.dirname(theme_path), exist_ok=True)
with open(
theme_path,
"w",
) as f:
f.write(theme_content)
"""
and
"""
with open(os.path.join(dst, "report.json"), "r") as f:
json_data2 = json.load(f)
report2 = Report(**json_data2)
report2.add_section(tmp_sec)
x = 10
y = 20
z = 0
width = 600
height = 400
report2.add_visual(
display_name=tmp_sec.displayName,
visual_config=create_visual_config(x, y, z, width, height),
x=x,
y=y,
z=z,
width=width,
height=height,
)
with open(os.path.join(dst, "report.json"), "w") as f:
f.write(report2.to_json())
"""
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @edwardlee4948 

As you mentioned, I have not found any open-source Python libraries specifically for handling PBIR and DIM files.

 

However, I discovered a project on GitHub called pbir-utils, which provides some useful functions for managing and manipulating PBIR metadata. I hope this is helpful to you:

vlinyulumsft_0-1733899451069.png

GitHub - akhilannan/pbir-utils: A tool for managing Power BI Enhanced Report Format (PBIR) projects


Secondly, regarding obtaining visual objects, you can try the following JavaScript content:

let pages = await page.getVisuals();

vlinyulumsft_1-1733899451071.png

For more details, please refer to:

Get pages and visuals in a Power BI embedded analytics application | Microsoft Learn

VisualDescriptor class | Microsoft Learn

 

Finally, you can also try the following third-party software to obtain visual object information:

vlinyulumsft_2-1733899507727.png

Power BI Reporting Best Practices Analyzer - Microsoft Fabric Community

Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi, @edwardlee4948 

As you mentioned, I have not found any open-source Python libraries specifically for handling PBIR and DIM files.

 

However, I discovered a project on GitHub called pbir-utils, which provides some useful functions for managing and manipulating PBIR metadata. I hope this is helpful to you:

vlinyulumsft_0-1733899451069.png

GitHub - akhilannan/pbir-utils: A tool for managing Power BI Enhanced Report Format (PBIR) projects


Secondly, regarding obtaining visual objects, you can try the following JavaScript content:

let pages = await page.getVisuals();

vlinyulumsft_1-1733899451071.png

For more details, please refer to:

Get pages and visuals in a Power BI embedded analytics application | Microsoft Learn

VisualDescriptor class | Microsoft Learn

 

Finally, you can also try the following third-party software to obtain visual object information:

vlinyulumsft_2-1733899507727.png

Power BI Reporting Best Practices Analyzer - Microsoft Fabric Community

Of course, if you have any new discoveries or questions, please feel free to get in touch with us.
 

Best Regards,

Leroy Lu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.