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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
Anonymous
Not applicable

DAX Formula

Hello everyone,

I need to check if the GPS coordinates (longitude and latitude) are the same on two tables (with a little variation/delta of +/- 0.0001).

Here is an example of my data from my table A :

Identifiant  PositionTimeStampp Long Lat SameLongitude SameLatitude
121/07/2022 14:50:00 47.307390 0.69521 Yes Yes
120/07/2022 14:40:00 47,25620 0,09238 Yes Yes
221/07/2022 13:50:00 47,28943  0,10107  No No
219/07/2022 13:40:00 47,25620 0,09237 Yes Yes

Here is an example of my data from my table B :

Identifiant GPS coordinates  Longitude Latitude
4 47.307390, 0.69522 47.307390 0.69522
5 47,25621, 0,09237 47,25621 0,09237

In these two tables:
- The first row of table A has (with variation) the same coordinates as the first row of table B.
- The second row and the fourth row of table A have (with the variation) the same coordinates as the second row of table B.
- However the third row of table A has no coordinates in common with table B

Do you have a solution or an idea ?

Best regards

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

What Data Type are the Lat and Long fields? (text, decimal number?)

 

A) If the fields are type Decimal Number:

 

Check Long =
VAR _v1 =
    FORMAT ( MAX ( Table1[Long] ), "#0.00000" )
VAR _T =
    VALUES ( 'Table 2'[Longitude] )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Longitude] ),
        "Longitude", 'Table 2'[Longitude] + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Longitude] ),
        "Longitude", 'Table 2'[Longitude] - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Longitude], "#0.00000" )
    )
RETURN
    IF ( _v1 IN _UN, "Yes", "No" )
Check Lat =
VAR _V1 =
    FORMAT ( MAX ( Table1[Lat] ), "#0.00000" )
VAR _T =
    VALUES ( 'Table 2'[Latitude] )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Latitude] ),
        "Latitude", 'Table 2'[Latitude] + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Latitude] ),
        "Latitude", 'Table 2'[Latitude] - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Latitude], "#0.00000" )
    )
RETURN
    IF ( _V1 IN _UN, "Yes", "No" )

 

dec number.png

B) If the Lat/long Fields are Type Text:

 

Check Long txt =
VAR _v1 =
    MAX ( Table1[TXT LONG] )
VAR _T =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Long] ),
        "Longitude", VALUE ( 'Table 2'[TXT Long] )
    )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Long] ),
        "Longitude", VALUE ( 'Table 2'[TXT Long] ) + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Long] ),
        "Longitude", VALUE ( 'Table 2'[TXT Long] ) - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Longitude], "#0.00000" )
    )
RETURN
    IF ( _v1 IN _UN, "Yes", "No" )
Check Lat txt =
VAR _V1 =
    MAX ( Table1[TXT LAT] )
VAR _T =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Lat] ),
        "Latitude", VALUE ( 'Table 2'[TXT Lat] )
    )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Lat] ),
        "Latitude", VALUE ( 'Table 2'[TXT Lat] ) + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Lat] ),
        "Latitude", VALUE ( 'Table 2'[TXT Lat] ) - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Latitude], "#0.00000" )
    )
RETURN
    IF ( _V1 IN _UN, "Yes", "No" )

 

txt.png

I've attached the sample PBIX

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

2 REPLIES 2
PaulDBrown
Community Champion
Community Champion

What Data Type are the Lat and Long fields? (text, decimal number?)

 

A) If the fields are type Decimal Number:

 

Check Long =
VAR _v1 =
    FORMAT ( MAX ( Table1[Long] ), "#0.00000" )
VAR _T =
    VALUES ( 'Table 2'[Longitude] )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Longitude] ),
        "Longitude", 'Table 2'[Longitude] + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Longitude] ),
        "Longitude", 'Table 2'[Longitude] - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Longitude], "#0.00000" )
    )
RETURN
    IF ( _v1 IN _UN, "Yes", "No" )
Check Lat =
VAR _V1 =
    FORMAT ( MAX ( Table1[Lat] ), "#0.00000" )
VAR _T =
    VALUES ( 'Table 2'[Latitude] )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Latitude] ),
        "Latitude", 'Table 2'[Latitude] + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[Latitude] ),
        "Latitude", 'Table 2'[Latitude] - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Latitude], "#0.00000" )
    )
RETURN
    IF ( _V1 IN _UN, "Yes", "No" )

 

dec number.png

B) If the Lat/long Fields are Type Text:

 

Check Long txt =
VAR _v1 =
    MAX ( Table1[TXT LONG] )
VAR _T =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Long] ),
        "Longitude", VALUE ( 'Table 2'[TXT Long] )
    )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Long] ),
        "Longitude", VALUE ( 'Table 2'[TXT Long] ) + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Long] ),
        "Longitude", VALUE ( 'Table 2'[TXT Long] ) - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Longitude], "#0.00000" )
    )
RETURN
    IF ( _v1 IN _UN, "Yes", "No" )
Check Lat txt =
VAR _V1 =
    MAX ( Table1[TXT LAT] )
VAR _T =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Lat] ),
        "Latitude", VALUE ( 'Table 2'[TXT Lat] )
    )
VAR _Tplus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Lat] ),
        "Latitude", VALUE ( 'Table 2'[TXT Lat] ) + 0.00001
    )
VAR _Tminus =
    SELECTCOLUMNS (
        VALUES ( 'Table 2'[TXT Lat] ),
        "Latitude", VALUE ( 'Table 2'[TXT Lat] ) - 0.00001
    )
VAR _UN =
    SELECTCOLUMNS (
        UNION ( _T, _Tplus, _Tminus ),
        "Text", FORMAT ( [Latitude], "#0.00000" )
    )
RETURN
    IF ( _V1 IN _UN, "Yes", "No" )

 

txt.png

I've attached the sample PBIX

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Hello Paul,

In my case, it was option B (my fields were of type Text)

Thank you for your answer, this seems correct for my need

Best regards

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.