cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
beingandbrian Regular Visitor
Regular Visitor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Using Python Instead of Measures

Hey @beingandbrian ,

 

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

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
I accept Kudos :-), If you find my post helpful.

Proud to be a Datanaut!

View solution in original post

5 REPLIES 5
Super User
Super User

Re: Using Python Instead of Measures

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

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
I accept Kudos :-), If you find my post helpful.

Proud to be a Datanaut!
beingandbrian Regular Visitor
Regular Visitor

Re: Using Python Instead of Measures

@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.

Highlighted
Super User
Super User

Re: Using Python Instead of Measures

Hey @beingandbrian ,

 

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

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
I accept Kudos :-), If you find my post helpful.

Proud to be a Datanaut!

View solution in original post

Re: Using Python Instead of Measures

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?

 

 

Super User
Super User

Re: Using Python Instead of Measures

Hey,

 

currently it's not possible to pass data from a python or r script visual back to Power Bi so that the data from the visula can be used inside a table or matrix viusal.

 

But maybe this article will provide you with some ideas:

https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.table.html

 

Regards,

Tom

Hamburg - Germany
If I answer your question, please mark my post as solution, this will also help others.
I accept Kudos :-), If you find my post helpful.

Proud to be a Datanaut!

Helpful resources

Announcements
New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (4,412)