Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Using Python Instead of Measures

Hey all,

 

Here's some background: I'm very familiar with python pandas. Not so familiar with Power BI measures. It's been ok, but DAX coding just doesn't come so easily to me.

I have a simple question:

Has anyone seen or used python scripts used in a data model instead of having to create a bunch of measures? 

 

Best.

  • Hey Anonymous ,

     

    I would not consider it a shame, as DAX is a "query language", whereas python is a "general purpose" programming language of course with great data processing support eg. pandas, ... not to mention all the things possible if we are considering more advanced algorithms.

     

    But DAX is designed to wade through billions, trillions of rows in real time, meaning a user changes the slicer selection.

     

    Personally I'm / we are (at enterprise level) using python to create more "composed" visuals, where the composition is more important than the interactivity provided by the default visuals that are based on d3.js.

    From an enterprise perspective we are not using python from within Power BI for data transformation directly, but of course python can be used together with Azure Databricks, providing tremendous possibilities :-)

     

    Regards,

    Tom

6 Replies

  • Hey,

     

    basically you can't compare measures with using python, this is due to the fact that python can "just" be used

    1. as a data source, or from within power query to process data or
      (please be aware that pyhton (and also R scripts) require the personal gateway mode, if data has to be refreshed automatically, this may be impacted by compliance requirements, if you have to bow to enterprise requirements) 
    2. to a create a visual

    In the 1st case the python script will just be executed on data refresh and not during user interactions like filtering data using slicers. Of course the viusal will adapt to other slicer slections.

     

    A measure can be "reused" in various visuals, whereas a python script has to be used multiple times, meaning multiple scripts have to be maintained.

     

    My recommendation, start using DAX and "just"use python, if DAX or M can't solve the problem.

     

    Regards,

    Tom

    • markturnbaugh's avatar
      markturnbaugh
      Regular Visitor

      When using python to create a visual the data is dynamically calculated based upon your slicers. Is there a way to get the data from a python visual and show it in a table, so that table dynamically changes with the visual?

       

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      TomMartens 

       

      Much appreciated man. Great insight that you could tell I was doing this within my company. That's a shame about Python, and I'll need to commit to measure in DAX. In what instances would people use Python scripts within Power BI? For 1-off reports mostly?

       

      Also, Hamburg is a great city, I lived there for 3 months in 2013. 

       

      Best.

      • TomMartens's avatar
        TomMartens
        Super User

        Hey Anonymous ,

         

        I would not consider it a shame, as DAX is a "query language", whereas python is a "general purpose" programming language of course with great data processing support eg. pandas, ... not to mention all the things possible if we are considering more advanced algorithms.

         

        But DAX is designed to wade through billions, trillions of rows in real time, meaning a user changes the slicer selection.

         

        Personally I'm / we are (at enterprise level) using python to create more "composed" visuals, where the composition is more important than the interactivity provided by the default visuals that are based on d3.js.

        From an enterprise perspective we are not using python from within Power BI for data transformation directly, but of course python can be used together with Azure Databricks, providing tremendous possibilities :-)

         

        Regards,

        Tom