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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.