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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Simon_G
Frequent Visitor

Find and return intersection points between lines

Hello,

I'm working on an analysis comparing scenarios and I would like to find the intersection point(s) between lines. Below is an example of a graph I can plot and I would like to calculate at what temparature the 2 lines meet. 

Simon_G_0-1742999344441.png

 

The data is stored in different tables for different scenarios but are linked by the temperature. The temperature is at 0.1C increment. Below is the example of the datatables I have. I have diffirent scenarios/variables and use scliers to display them on a graph. The graph example shows sum(GHG value 1) and sum(GHG value 2). I would also create measures the would sum GHG values 1 & 2 as one and plot another line for sum GHG values 2 & 3 for example.  

 

TemperatureScenarios 1Additional variablesGHG value 1
0Scenario aVariable 2395
0.1Scenario aVariable 2391
0.2Scenario aVariable 2387
0Scenario bVariable 2450
0.1Scenario bVariable 2432

 

TemperatureScenarios 2Additional variablesGHG value 2
0Variable 1Variable 2395
0.1Variable 1Variable 2391
0.2Variable 1Variable 2387

 

Do you know of a DAX measure that could be used to find the interect point(s) (could be several) and what temperature it is?

 

Thank you for your help. 

 

1 ACCEPTED SOLUTION
Deku
Community Champion
Community Champion

replace

SELECTCOLUMNS (
   IntersectionPointsTable, 
   "Temperature", [Temperature],
   "GHGValue1", [GHGValue1],
   "GHGValue2", [GHGValue2]
)

with

CONCATENATEX(
   IntersectionPointsTable,
   [Temperature],
   ", ",
   [Temperature], ASC
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!

View solution in original post

13 REPLIES 13
v-csrikanth
Community Support
Community Support

Hi Simon_G,

 

Thank you for reaching out to the Microsoft Community Forum.

 

 

This DAX measure will create a table (IntersectionPoints) that captures the temperature at which the lines intersect. It calculates the difference between the GHG values from the two tables and filters the results to find the points where the absolute difference is less than 0.1, indicating an intersection.

 

You can use this measure to analyze the intersection points and the corresponding temperatures for your scenarios.

 

DAX code :

 

IntersectionPoints = 
VAR TempTable1 = 
    SELECTCOLUMNS (
        Table1,
        "Temperature", Table1[Temperature],
        "GHGValue1", Table1[GHG value 1]
    )
VAR TempTable2 = 
    SELECTCOLUMNS (
        Table2,
        "Temperature", Table2[Temperature],
        "GHGValue2", Table2[GHG value 2]
    )
VAR CombinedTable = 
    NATURALINNERJOIN ( TempTable1, TempTable2 )
VAR IntersectionPointsTable = 
    FILTER (
        ADDCOLUMNS (
            CombinedTable,
            "Difference", [GHGValue1] - [GHGValue2]
        ),
        ABS ( [Difference] ) < 0.1
)
RETURN
    SELECTCOLUMNS (
        IntersectionPointsTable,
        "Temperature", [Temperature],
        "GHGValue1", [GHGValue1],
        "GHGValue2", [GHGValue2]
    )

 

 

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

 

Thank you for the response. I wrote the dax as noted above but I come to this error:
"An incompatible join column, (''[Temperatures]) was detected. 'NATURALINNERJOIN' doesn't support joins by using columns with different data types or lineage." All data is decimal number so I'm not sure what the issue is. 
Thank you

Deku
Community Champion
Community Champion

DAX has a concept know as lineage, it knows for given values, what column they originated from. Added a TREATAS, to change the lineage of the temperature from temp table2

 

IntersectionPoints =
VAR TempTable1 =
SELECTCOLUMNS (
Table1,
"Temperature", Table1[Temperature],
"GHGValue1", Table1[GHG value 1]
)
VAR TempTable2 =

TREATAS(
SELECTCOLUMNS (
Table2,
"Temperature", Table2[Temperature],
"GHGValue2", Table2[GHG value 2]
),

Table1[Temperature],

Table2[GHG value 2]

)

 

VAR CombinedTable =
NATURALINNERJOIN ( TempTable1, TempTable2 )
VAR IntersectionPointsTable =
FILTER (
ADDCOLUMNS (
CombinedTable,
"Difference", [GHGValue1] - [GHGValue2]
),
ABS ( [Difference] ) < 0.1
)
RETURN
SELECTCOLUMNS (
IntersectionPointsTable,
"Temperature", [Temperature],
"GHGValue1", [GHGValue1],
"GHGValue2", [GHGValue2]
)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Simon_G
Frequent Visitor

Thank you for the response, it seems to have that issue, now I get "No common join columns detected. The join function 'NATURALINNERJOIN' requires at-least one common join column.".

All temperatures column are linked to a temperature table (that just list all the temperature once)

Deku
Community Champion
Community Champion

Adjusted the start to consider the temperature table, assume relationship to the other two tables

 

IntersectionPoints =

VAR tbl =

Addcolumns(

Temperatures[temperature],

"GHGValue1", 

Calculate( max( Table1[GHG value1])),

"GHGValue2", 

Calculate( max( Table2[GHG value2]))

)

 

VAR IntersectionPointsTable =

FILTER (

ADDCOLUMNS (

Tbl,

"Difference", [GHGValue1] - [GHGValue2]

),

ABS ( [Difference] ) < 0.1

)

RETURN

SELECTCOLUMNS (

IntersectionPointsTable,

"Temperature", [Temperature],

"GHGValue1", [GHGValue1],

"GHGValue2", [GHGValue2]

)


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Simon_G
Frequent Visitor

Thank you for the reply. Unfortunatly I still have an error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value"

Deku
Community Champion
Community Champion

replace

SELECTCOLUMNS (
   IntersectionPointsTable, 
   "Temperature", [Temperature],
   "GHGValue1", [GHGValue1],
   "GHGValue2", [GHGValue2]
)

with

CONCATENATEX(
   IntersectionPointsTable,
   [Temperature],
   ", ",
   [Temperature], ASC
)

Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Simon_G
Frequent Visitor

Looks like it worked in the end. I just had to change Max to Sum. 

 

Thank you!

v-csrikanth
Community Support
Community Support

Hi @Simon_G 
It's been a while since I heard back from you and I wanted to follow up. Have you had a chance to try the solutions that have been offered?
If the issue has been resolved, can you mark the post as resolved? If you're still experiencing challenges, please feel free to let us know and we'll be happy to continue to help!
Looking forward to your reply!


Hello, I still haven't found a solution to my problem (but it seems there isn't an easy solution to it).

v-csrikanth
Community Support
Community Support

Hi @Simon_G 

Thank you for reaching out to the Microsoft Community Forum.
Could you please provide more details, including the steps you have taken so far and what you are expecting? These details will help us better understand your issue and guide you in solving it.
Could you please share the expected output snapshot.

Thank you.

 

Deku
Community Champion
Community Champion

You can linestx to get the y = mx + a for the straight line.

The curved one will be more difficult.

If you had both definitions you could solve exactly with some algebra. 

 

You could estimate the points. Would that be acceptable?


Did I answer your question?
Please help by clicking the thumbs up button and mark my post as a solution!
Simon_G
Frequent Visitor

That would be complicated as some of the data is more in buckets (is flat for a few temperature points then changes) and some is not linear (like example above)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.