Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
abubakarsiddiq7
Contributor III
Contributor III

how to find distance between two pin codes using geo analytics

Hi ,

i am trying to find the distance between two different pin codes using geo analytics but i am failed can any one help me on this.

here is my code 

rutt:
LOAD
routeid,
// TicketID,
// "Start",
// Start_Country,
// "end",
// End_Country,
Startpincode,
Endpincode
FROM [lib://AttachedFiles/GeoSampledata_Pincode.xlsx]
(ooxml, embedded labels, table is rutt);


//==================Geo Coding===============================


LIB CONNECT TO 'Geo Connection';

/* Generated by GeoAnalytics for operation Routes ---------------------- */
[_inlineMap_]:
mapping LOAD * inline [
_char_, _utf_
"'", '\u0027'
'"', '\u0022'
"[", '\u005b'
"/", '\u002f'
"*", '\u002a'
";", '\u003b'
"}", '\u007d'
"{", '\u007b'
"`", '\u0060'
"´", '\u00b4'
" ", '\u0009'
];

IF FieldNumber('routeid', 'rutt') = 0 THEN
call InvalidInlineData('The field routeid in rutt is not available');
END IF
IF FieldNumber('Startpincode', 'rutt') = 0 THEN
call InvalidInlineData('The field Startpincode in rutt is not available');
END IF
IF FieldNumber('Endpincode', 'rutt') = 0 THEN
call InvalidInlineData('The field Endpincode in rutt is not available');
END IF
Let [routeInlineTable] = 'routeid' & Chr(9) & 'Startpincode' & Chr(9) & 'Endpincode';
Let numRows = NoOfRows('rutt');
Let chunkSize = 1000;
Let chunks = numRows/chunkSize;
For n = 0 to chunks
Let chunkText = '';
Let chunk = n*chunkSize;
For i = 0 To chunkSize-1
Let row = '';
Let rowNr = chunk+i;
Exit for when rowNr >= numRows;
For Each f In 'routeid', 'Startpincode', 'Endpincode'
row = row & Chr(9) & MapSubString('_inlineMap_', Peek('$(f)', $(rowNr), 'rutt'));
Next
chunkText = chunkText & Chr(10) & Mid('$(row)', 2);
Next
[routeInlineTable] = [routeInlineTable] & chunkText;
Next
chunkText=''


[Routes]:
SQL SELECT [routeid], [route_Distance], [route_Duration], [route_Status], [route_PathLowRes] FROM Routes(criteria='fastest', transportation='car', dest='EndPincode', destType='NamedPoint', suffix='XPC', dataset='route')
DATASOURCE route INLINE tableName='rutt', tableFields='routeid,Startpincode,Endpincode', geometryType='LOCATIONNAMEDPOINT', loadDistinct='NO', suffix='XPC', crs='Auto' {$(routeInlineTable)}
SELECT [routeid], [Startpincode], [Endpincode] FROM route;
[route]:
SQL LOAD * FROM route;
tag field [routeid] with '$primarykey';
tag field [route_PathLowRes] with '$geoline';
tag field [routeid] with '$geoname';
tag field [route_PathLowRes] with '$relates_routeid';
tag field [routeid] with '$relates_route_PathLowRes';
tag field [routeid] with '$primarykey';
tag field [Startpincode] with '$geopoint';
tag field [routeid] with '$geoname';
tag field [Startpincode] with '$relates_routeid';
tag field [routeid] with '$relates_Startpincode';

[routeInlineTable] = '';

 

Note: I am using Qliksense nov2019 Release

Thanks,

Abubakar

Labels (1)
1 Reply