Forum Discussion

William29's avatar
William29
Helper I
4 years ago
Solved

How to refer to a dataset under 'fields' using python script in powerBi

 

In the image above you can see that I have the dataset 'Prop12' under fields. It has been imported into PowerBi.

 

Now how do I get access to that dataset within the python interface that PowerBI. In other words if I go to

"get data'->'More'->'Python Script' and click connect the python interface comes up as per the screen shot below:

 

If I want to load PowerBi's version of the dataset Prop12 and call it x, what do I type within the python script box. Note I am not talking about reading the original csv file that contains Prop 12 that was used to import it into PowerBI. I specifically want to load the version of Prop 12 mentioned in PowerBi, so that if I use powerquery to make some changes to it, it is the changed version that is loaded in the python script interface.

 

If it helps this is the link to the report: https://drive.google.com/file/d/1qXVDJVwccvrIBggvHy7RTlt5rLYHAjP0/view?usp=sharing

And this is the link to the dataset, containing Prop 12: https://drive.google.com/file/d/1E0aWMCECOWdsMTZFUPUMYaAS6dhUsrTU/view?usp=sharing

 

6 Replies

  • Hey William29 ,

     

    it's important to understand that there are data layers, each data layer is separate from each other, it's not possible to create an interaction between these layers.

    1. Layer 1 (Power Query) - Extract and transform source data
    2. Layer 2 (Power BI dataset) - data will be loaded from the PQ layer into the data model (stored inside the vertipaq engine) durig data refresh
    3. Layer 3 (Interaction layer) - measure layer, this layer is also part of the Power BI dataset, but for better understanding I imagine measures as a separate layer.

    As it's not possible to access data from subsequent layers you have to use the table that is created by importing the csv.

    You have to consider that transforming data using python during an automated refresh requires an installation of the Power BI gateway using the personal mode.

    Hopefully, this provides some ideas on to tackle your challenge.

     

    Regards,

    Tom 

    • William29's avatar
      William29
      Helper I

      Hello TomMartens,

       

      Could you explain more about what you mean by the 'PowerBi gateway using the personal mode'

       

      With regard to the original question of the post are you using that when using python within PowerBi, that the only datasets I can access are the original csv files that were used to import the data into PowerBi, I cannot access (within python) the data in its imported form?

       

      You mention that in layer 2, that the data is loaded from the PQ layer. However I thought that layer 2 cannot access the results of layer 1 and so wouldn not be able to access the data from the PQ layer. I thought the only thing it could access is  the table created when importing from csv?