Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I would like to calculate TravelArea for several GPS coordinate that are contained in my table Temp_Geo.
Temp_Geo (Sensible data have been replaced by hidden in this post):
1 | 10 | Family Home | 51 | 5 | [Hiden] | pedestrian | 30 | minutes |
2 | 10 | Family Home | 51 | 5 | [Hiden] | pedestrian | 1 | hours |
3 | 10 | Family Home | 51 | 5 | [Hiden] | car | 30 | minutes |
4 | 10 | Family Home | 51 | 5 | [Hiden] | car | 1 | hours |
5 | 20 | Creche | 51 | 5 | [Hiden] | pedestrian | 30 | minutes |
6 | 20 | Creche | 51 | 5 | [Hiden] | pedestrian | 1 | hours |
7 | 20 | Creche | 51 | 5 | [Hiden] | car | 30 | minutes |
8 | 20 | Creche | 51 | 5 | [Hiden] | car | 1 | hours |
9 | 30 | Hiden | 51 | 5 | [Hiden] | pedestrian | 30 | minutes |
10 | 30 | Hiden | 51 | 5 | [Hiden] | pedestrian | 1 | hours |
11 | 30 | Hiden | 51 | 5 | [Hiden] | car | 30 | minutes |
12 | 30 | Hiden | 51 | 5 | [Hiden] | car | 1 | hours |
I succeeded in creating a loop loading a single row, making a Geo Querry and placing the variable inside the load querry:
let vTravelDuration = Peek('Travel_Duration',$(x),'Temp_Geo');
let vTravelMode = Peek('Travel_Mode',-$(x),'Temp_Geo');
let vTravelMeasure = Peek('Travel_Measure',$(x),'Temp_Geo');
Load * Extension GeoOperations.ScriptEval('
SELECT _autoIndex_, TravelArea, Cost, CostUnit, Status, dataset.Long_Lat FROM
TravelAreas(costValue="$(vTravelDuration)", costUnit="$(vTravelMeasure)", transportation="$(vTravelMode)")
DATASOURCE dataset INTABLE crs="auto", pointField="Long_Lat"
', Temp_Geo);
Is there a more practical way to do it ? Making a load at each step of a loop isn't a good practice in my experience.I will need to execute this kind of querry with much more data and i would love to use te more efficient way possible.
Thanks in advance for your return 🙂
its hard to understand the relationships between what you are loading and what appears to be 3 other data set. but from what i can see, you are really looking yup values from 3 different tables and plugging it into your select statement. i would suggest 1 of 3 ways to do this:
1. at data layer, join your 4 tables (there must be some link which allows you to look the 3 values up) - that is if your 3 lookup tables are also in your DB
the next 2 if your lookup tables arent in the same DB as your datasource
2.load your main table and use either 3 applymap functions to lookup the 3 fields
3.load your main table and do 3 inner (or left) joins to the 3 lookup tables.
if you decide to do either 2 or 3 you may want to run both and decide which one is faster. inner joins in QLik appear to slow down in large volumes.
i prefer table operations to peek for large tables.
hope that helps
I realise i didn't specify field Names.
I use one table that contains the value of the three variable (3 field). Theses values need then to be inserted in the Geo Operation Querry. Wonder If there is another method than a loop
regardless, what i suggested is to use table operations instead of loops. loops tend to degrade performance once you hit large volumes