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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Python and Power BI

I will transform invoice data inside powerBI to then analyze this. The invoices have several sections to show where the sums in the total amount come from. When I try to retrieve the invoice data, powerBI only manages to retrieve the bottom line with the KID number, but not the total amount or the various subtotals. My idea was to use python to clean up the invoice and create a format that powerBI can read, so that all the data comes with it. But here I need your help, how do I do this? Since I am a summer student in a company, I have limited access and am unable to connect vscode to powerBI. How should I transform the documents?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous ,

 

You can perform data cleansing and perform advanced data shaping and analysis on a dataset using Python directly from within the Power Query editor in Power BI Desktop.

For example:

import pandas as pd
completedData = dataset.fillna(method='backfill', inplace=False)
dataset["completedValues"] = completedData["SMI missing values"]

You can find the procedure and related restrictions in the official documentation below, hopefully it will help you:

Use Python in Power BI Power Query Editor - Power BI | Microsoft Learn

This is the related document, you can view this content:

powerbi - Power BI: How to process/clean string data using Python? - Stack Overflow

https://stackoverflow.com/questions/51947441/power-bi-how-to-use-python-with-multiple-tables-in-the-power-query-editor/51947461#51947461

random - How to make a reproducible data sample in PowerBI using Python? - Stack Overflow

 

Best Regards,

Liu Yang

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  @Anonymous ,

 

You can perform data cleansing and perform advanced data shaping and analysis on a dataset using Python directly from within the Power Query editor in Power BI Desktop.

For example:

import pandas as pd
completedData = dataset.fillna(method='backfill', inplace=False)
dataset["completedValues"] = completedData["SMI missing values"]

You can find the procedure and related restrictions in the official documentation below, hopefully it will help you:

Use Python in Power BI Power Query Editor - Power BI | Microsoft Learn

This is the related document, you can view this content:

powerbi - Power BI: How to process/clean string data using Python? - Stack Overflow

https://stackoverflow.com/questions/51947441/power-bi-how-to-use-python-with-multiple-tables-in-the-power-query-editor/51947461#51947461

random - How to make a reproducible data sample in PowerBI using Python? - Stack Overflow

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.