Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Came out of this conversation: Create Origin To Destination Map In BI Desktop - Microsoft Fabric Community. Here's a way to create origin to destination lines on a map given a table of cities.
CityLatitudeLongitude
| Columbus, OH | 39.9611111 | -82.9988889 |
| London, UK | 51.5 | -0.116667 |
| Kansas City | 39.099912 | -94.581213 |
| St. Louis | 38.627089 | -90.200203 |
From and To =
VAR __NumSteps = 100
VAR __Steps = SELECTCOLUMNS( GENERATESERIES( 1, __NumSteps, 1 ), "Step", [Value] )
VAR __BaseTable =
FILTER(
GENERATE(
SELECTCOLUMNS( 'Cities', "From City", [City], "From Long", [Longitude], "From Lat", [Latitude] ),
SELECTCOLUMNS( 'Cities', "To City", [City], "To Long", [Longitude], "To Lat", [Latitude] )
),
[From City] <> [To City]
)
VAR __String = CONCATENATEX( __BaseTable, [From City] & "^" & [From Long] & "^" & [From Lat] & "^" & [To City] & "^" & [To Long] & "^" & [To Lat], "|" )
VAR __Count = COUNTROWS( __BaseTable )
VAR __Table =
ADDCOLUMNS(
GENERATESERIES( 1, __Count ),
"__Data", SUBSTITUTE( PATHITEM( __String, [Value] ), "^", "|" )
)
VAR __Result =
FILTER(
SELECTCOLUMNS(
ADDCOLUMNS(
GENERATE(
__Table,
__Steps
),
"Latitude", PATHITEM( [__Data], 3 ) + ( [Step] / __NumSteps ) * ( PATHITEM( [__Data], 6 ) - PATHITEM( [__Data], 3 ) ),
"Longitude", PATHITEM( [__Data], 2 ) + ( [Step] / __NumSteps) * ( PATHITEM( [__Data], 5 ) - PATHITEM( [__Data], 2 ) )
),
"Latitude", [Latitude],
"Longitude", [Longitude],
"From", PATHITEM( [__Data], 1 ),
"To", PATHITEM( [__Data], 4 )
),
[From] <> [To]
)
RETURN
__Result
eyJrIjoiMDZkNjhlMmItZTg1ZC00ZmM2LTkwZTEtNDJiZDA3ZGFlNDRjIiwidCI6Ijg3NDlmOWI5LWYzMmQtNDdhMS1hMjI0LTM2OTQxOGFlMmY1MSJ9
Awesome! Great sample using the Azure Maps Visual in Power BI! For anyone that wants to try, check out Get started with Azure Maps Power BI visual - Microsoft Azure Maps | Microsoft Learn