Forum Discussion

gnotcirdec's avatar
gnotcirdec
Frequent Visitor
4 years ago
Solved

Comparing latitude and longitude in a table against different table of latitude and longitudes

Hello.   I'm trying to compare data points in different tables to see if they are within each other. If tableA latitude and longitude are inside any of the points inside fence indicated by tableB, ...
  • v-jingzhang's avatar
    4 years ago

    Hi gnotcirdec 

     

    Here is a DAX method. You can create a new column with below code.

    Is Inside = 
    VAR _table =
        ADDCOLUMNS (
            TableB,
            "IsInsideFlag",
                IF (
                    TableA[Latitude] >= TableB[BottomLatitude]
                        && TableA[Latitude] <= TableB[TopLatitude]
                        && TableA[Longitude] >= TableB[TopLongitude]
                        && TableA[Longitude] <= TableB[BottomLongitude],
                    1,
                    0
                )
        )
    RETURN
        IF ( COUNTROWS ( FILTER ( _table, [IsInsideFlag] = 1 ) ) >= 1, 1, 0 )
    

     

    Best Regards,
    Community Support Team _ Jing
    If this post helps, please Accept it as Solution to help other members find it.

  • AlexisOlson's avatar
    AlexisOlson
    4 years ago

    Try changing the last line of [Is Inside] to

    MINX ( FILTER ( _table, [IsInsideFlag] = 1 ), [Location] )