Forum Discussion
Overlaying graphs with independant tables using python or ...
- Anonymous1 year ago
Hi NicoBoss
Thank you very much govind_021 for your prompt reply.
If Time1 is not equal to Time2, I suggest you create a bridge table as follows:
“Time1”
"Time2"
Create a new table.
Bridge Table = UNION( SELECTCOLUMNS( 'Table1', "Time", 'Table1'[Time1]), SELECTCOLUMNS( 'Table2', "Time", 'Table2'[Time2]) )Table1 and Table2 create relationships with the bridge table respectively.
Create a Python visual.
import matplotlib.pyplot as plt # Create figure and axis ax = plt.gca() dataset.plot(kind= "line", x='Time1', y='Depth1', color= "Red", ax= ax) dataset.plot(kind= "line", x='Time2', y='Depth2', color= "Blue", ax= ax) # Show plot plt.show()Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi NicoBoss
Can you give more context to your question by adding images of the problem , if confidential then with dummy data.
Thanks Sure, I tried the code below.
This code is working fine if Time1=Time2, then i can create a table with 3 column only, X=Time1 Y1=Depth1 and Y2=Depth2 and plot 2 curves.
But Time1≠Time2, also the table1 is not the same size as table2, so I cannot merge and I get the error : "can't display the data because PowerBI can't determine the relationship between two or more fields"
Indeed they are 2 different tables from 2 different queries.
Time1/Depth1 and Time2/Depth2 are from 2 different datatables in the same powerbi, I opened a Py-Python Visual, draged and droped those tables in the "Values" field.
Basically just want to overlay 2 curves (without the same dimension), should be easy? I am struggling for more than 1 day... I read it is not so easy in PowerBI DAX but they are ways around, but so far still searching...
---
- Anonymous1 year agoNot applicable
Hi NicoBoss
Thank you very much govind_021 for your prompt reply.
If Time1 is not equal to Time2, I suggest you create a bridge table as follows:
“Time1”
"Time2"
Create a new table.
Bridge Table = UNION( SELECTCOLUMNS( 'Table1', "Time", 'Table1'[Time1]), SELECTCOLUMNS( 'Table2', "Time", 'Table2'[Time2]) )Table1 and Table2 create relationships with the bridge table respectively.
Create a Python visual.
import matplotlib.pyplot as plt # Create figure and axis ax = plt.gca() dataset.plot(kind= "line", x='Time1', y='Depth1', color= "Red", ax= ax) dataset.plot(kind= "line", x='Time2', y='Depth2', color= "Blue", ax= ax) # Show plot plt.show()Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.