Search code examples
pythonimportpowerbipowerqueryschedule

Getting data in a folder with Python to provide excel files to Power BI


I have been trying to do this but I wonder if this possible in the first place. I have a power bi file on my computer, which is taking a file in a folder each day in a specific folder. I would like to be able to use a python script to automatically feed this execel file to the PBI file that I have, each day, at a given time.

I have found the following code, but I am encountering issues, despite having installed pip.

pbixrefresher <WORKBOOK> [-workspace <WORKSPACE>] [--refresh-timeout <REFRESH_TIMEOUT>] [--no-publish]

Is what I am doing actually possible, or is it not possible?


Solution

  • Reading the latest file from a SharePoint folder is a rather simple task in PowerQuery: If you're in MSTeams goto the files section of your channel and "Open in SharePoint". Then you copy the first part of the path shown in your browser, everything before "/Shared%20Documents/Forms/AllItems.aspx ..."

    In PBI Desktop you select "Get Data" from "SharePoint folder" and paste the copied url. Then you filter the records to your needs and sort descending on the "Date modified" column. Eventually you pick "Keep top rows", number=1, and by clicking on "Binary" in the "Contents" column you'll get your data.