How i can split column delimited by , in SSAS DAX

Viewed 1821

I have GPS coordinates in my column (latitude and longitude separated by ,) and I am trying to get them into two separate columns.

I am using the below formula but it is not working.

= PATHITEM ( SUBSTITUTE ( Fault[lastgps], “,”, “|” ), 1 )

1 represents position.

2 Answers

Your quotes look weird to me. Does this work?

= PATHITEM ( SUBSTITUTE ( Fault[lastgps], ",", "|" ), 1 )

Try this to handle different lat long sizes and separators:

EVALUATE
VAR V_Str = "-23.1232630, -46.68211551"
VAR V_Sep = ", "
VAR V_Pos = FIND(V_Sep,V_Str) 

RETURN
    ROW(
        "Lat",LEFT(V_Str,V_Pos-1),
        "Long",RIGHT(V_Str,LEN(V_Str)-LEN(V_Sep)-V_Pos+1)
    )
Related