Forum Discussion

Piyush_97's avatar
Piyush_97
New Member
3 years ago
Solved

exporting the data from BI service using python

How i can export the data from power BI service using python?? or simply  how to write a code in python for POWER BI service  for exporting data in a file ??
  • ibarrau's avatar
    3 years ago

    Hi. PowerBi can't run python on demand. You have two alternatives to export data with python:

    1- Prepare the code on the ETL. If you write a python transformation on PowerQuery, that means you need a gateway and a VM to run the transformations. That will let you write a code to export the current frame to the local filesystem of the VM and continue with the steps of the query to load the usual data. You can read more here: https://blog.ladataweb.com.ar/post/617917545084846080/powerbi-exportar-un-datos-automáticamente-al

    2- Execute a DAX Query to the dataset with the PowerBi Rest API. There is a request on the API that let's you run a query against the model. You could run it, store it on a variable and export if you want. More info: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/execute-queries

    If you like python I would suggest using a Python lib to make the code for the API easier. Something like SimplePBI that already has an object dataset to execute the query with a parameter to return a pandas dataframe.

    I hope that helps,