Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Python Visual dataset Input as variable

Hi All,

 

Im attempting to display a compass using the pyhton visual in power BI to show the current wave direction from a sensor in the sea. 

 

It works when i define a varible in the script, but the problem arises when i want to use the data i have in one of my datasets.

 

Can the dataset be used as a variable and how ?

I have the latest angle which is what I want to use to create the graph that represents a compass.

 

any help greatly appreciated

 
4 REPLIES 4
Anonymous
Not applicable

I can try describe it better,

I have wave data for the past year. i have filtered it to only be the most recent data avaliable. It is an angle that corresponds to the direction of the waves.

 

I would like to display this angle on a compass so it is easy to understand for my client.

i have coded a graph that looks like a compass in python. 

 

I need to take the single most recent data value and use it in my python script to create the arrow (display direction).

So my question is how you take data in power BI and use it as a variable to be used for calculations in the python visual. 

Anonymous
Not applicable

Here is my code:

 

# dataset = pandas.DataFrame(Theta_p)
# dataset = dataset.drop_duplicates()
 
# Plot circle
theta = np.linspace( 0 , 2 * np.pi , 150 )

radius = 1
 
x = radius * np.cos( theta )
y = radius * np.sin( theta )
 
#recieving coordinate
rec_alpha = Theta_p

a = radius * np.cos( rec_alpha )
b = radius * np.sin( rec_alpha )
plt.scatter(a,b, c='red', s=100, label='Recieveing')

#outward coordinate
out_alpha = rec_alpha - np.pi

c = radius * np.cos( out_alpha )
d = radius * np.sin( out_alpha )
plt.scatter(c,d, color='lime', s=100, label='Outgoing')

# plot line between
x_values = [a, c]
y_values = [b, d]
plt.plot(x_values, y_values, "r-", 'bo', linestyle="--")


plt.show()
Anonymous
Not applicable

Hi @Anonymous ,

 

You could extract the data from a visual.

Please kindly refer to

Export data from a Power BI visualization - Power BI | Microsoft Docs

 

Best Regards,

ShundaSteph

 

amitchandak
Super User
Super User

@Anonymous , Not very clear. You can use the dataset as a source

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.