Está en la página 1de 16

GOOGLE MAPS:

// Google Maps in QlikView


// V0.85.2 - October 1st 2008
AES

Copyright QlikTech International AB 2008 /

// Google Maps Key


// get a key here http://code.google.com/apis/maps/signup.html
gmap_key = 'xx';
max_zoom_level = 17; //maximum value 17
// Variables required for calculating map
// No need to change these
var_pi180=
'=pi()/180';
var_lat_offset=
'0';
var_mc2=
'=256*pow(2,$(var_zoom))';
var_mc1=
'=256*pow(2,($(var_zoom)-1))';
var_mid_lat= '=min(latitude)+(1+var_lat_offset)*((max(latitude)min(latitude))/2)';
var_mid_long='=min(longitude)+(max(longitude)-min(longitude))/2';
var_zoom=
'=max(aggr(if(max( round(256*pow(2,(_zoom_level -1)))+
( longitude *((256*pow(2,_zoom_level ))/360)) )-min( round(256*pow(2,
(_zoom_level -1)))+( longitude *((256*pow(2,_zoom_level ))/360)) )
<map_size_x AND max((256*pow(2,(_zoom_level-1)))+((0.5*log((1+
(sin((latitude)*pi()/180)))/(1-(sin((latitude)*pi()/180)))))*((256*pow(2,_zoom_level))/(2*pi()))))-min((256*pow(2,(_zoom_level-1)))+
((0.5*log((1+(sin((latitude)*pi()/180)))/(1-(sin((latitude)*pi()/180)))))*((256*pow(2,_zoom_level))/(2*pi()))))<map_size_y,_zoom_level,1),_zoom_level))';
var_maptype= '=if(isnull(only(maptype)),fieldvalue( '&chr(39)&'maptype'&chr(39
)&', 1 ),maptype)';
map_size_x=
'640';
map_size_y=
'400';
SET HidePrefix='_' ;
// Field required for calcualting best zoom level
_zoom_level:
Load RecNo( ) as _zoom_level autogenerate(max_zoom_level);
maptype:
LOAD * INLINE [
maptype
roadmap
mobile
satellite
terrain
hybrid
];

DEMORAS:
TiemposProcesos:
LOAD
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo Material],
[Nmero Transporte],
[Patente Camin],[Nro ODC], [Posicin ODC])
as keyDemora,
FFO,
FLO,
FEC,
FEP,
FCP,
FCO,
if((if(isnull(if(FLO>FEP,FFO-FLO,if(FFO<FEP,0,FFO-FEP))),0,
if(FLO>FEP,FFO-FLO,if(FFO<FEP,0,FFO-FEP))))<0,0,
(if(isnull(if(FLO>FEP,FFO-FLO,if(FFO<FEP,0,FFO-FEP))),0,

if(FLO>FEP,FFO-FLO,if(FFO<FEP,0,FFO-FEP)))))
as
[Demora de Facturacion],
if(isnull(if(FLO<FEP,0,FLO-FEP)),0,if(FLO<FEP,0,FLO-FEP)) as [Demora de
Liberacion],
if(isnull(if(FFO>FEP,FEC-FFO,if(FEC<FEP,0,FEC-FEP))),0,
if(FFO>FEP,FEC-FFO,if(FEC<FEP,0,FEC-FEP)))
as [Demora de Entrega],
if((if(isnull(FCO),FCP,FCO) - FCP)<0,0,
(if(isnull(FCO),FCP,FCO) - FCP))
as [Tiempo Confeccion ODC],
if(isnull(FLO),if(isnull(FCO),FCP,FCO),FLO) if(isnull(FCO),FCP,FCO)
as [Tiempo Liberacion ODC],
if((FFO - if(isnull(FLO),if(isnull(FCO),FCP,FCO),FLO))<0,
0,(FFO - if(isnull(FLO),if(isnull(FCO),FCP,FCO),FLO)))
as
[Tiempo Facturacion],
if(isnull(FEC),FFO,FEC) - FFO
as [Tiempo Entrega],
[Peso neto por etapa]
as [Peso Neto]
FROM $(rootQvdsIntermedio)\TiemposProcesos.qvd (qvd)
where not(isnull(FCP));
left join (TiemposProcesos)
LOAD
keyDemora,
[Demora de Entrega]+[Demora de Facturacion]+[Demora de Liberacion]
as [Demora Total],
[Tiempo Confeccion ODC]+[Tiempo Liberacion ODC]+[Tiempo Facturacion]+
[Tiempo Entrega]
as [Tiempo Proceso]
Resident TiemposProcesos;
//rangos demoras
rangodemorasFact:
LOAD
[Lmite Inferior] as [Lmite Inferior Demoras Fact],
[Lmite Superior] as [Lmite Superior Demoras Fact],
Descripcin
as [Rango Tiempo Demoras Fact]
FROM $(rootQvdsBase)\rangosdemoras.qvd (qvd);
rangodemoraFacturacion:
IntervalMatch ([Demora de Facturacion])
load
[Lmite Inferior Demoras Fact],
[Lmite Superior Demoras Fact]
resident rangodemorasFact;
rangodemorasLib:
LOAD
[Lmite Inferior] as [Lmite Inferior Demoras Lib],
[Lmite Superior] as [Lmite Superior Demoras Lib],
Descripcin
as [Rango Tiempo Demoras Lib]
FROM $(rootQvdsBase)\rangosdemoras.qvd (qvd);
rangodemoraLiberacion:
IntervalMatch ([Demora de Liberacion])
load
[Lmite Inferior Demoras Lib],
[Lmite Superior Demoras Lib]
resident rangodemorasLib;
rangodemorasEnt:
LOAD
[Lmite Inferior] as [Lmite Inferior Demoras Ent],
[Lmite Superior] as [Lmite Superior Demoras Ent],
Descripcin
as [Rango Tiempo Demoras Ent]
FROM $(rootQvdsBase)\rangosdemoras.qvd (qvd);

rangodemoraEntrega:
IntervalMatch ([Demora de Entrega])
load
[Lmite Inferior Demoras Ent],
[Lmite Superior Demoras Ent]
resident rangodemorasEnt;
rangodemorasTot:
LOAD
[Lmite Inferior] as [Lmite Inferior Demoras Tot],
[Lmite Superior] as [Lmite Superior Demoras Tot],
Descripcin
as [Rango Tiempo Demoras Tot]
FROM $(rootQvdsBase)\rangosdemoras.qvd (qvd);
rangodemoraTotal:
IntervalMatch ([Demora Total])
load
[Lmite Inferior Demoras Tot],
[Lmite Superior Demoras Tot]
resident rangodemorasTot;
//rangos lead times
rangoltConf:
LOAD
[Lmite Inferior] as [Lmite Inferior LT Conf],
[Lmite Superior] as [Lmite Superior LT Conf],
Descripcin
as [Rango Tiempo LT Conf]
FROM $(rootQvdsBase)\rangosleadtimes.qvd (qvd);
rangoltConfeccion:
IntervalMatch ([Tiempo Confeccion ODC])
load
[Lmite Inferior LT Conf],
[Lmite Superior LT Conf]
resident rangoltConf;
rangoltLib:
LOAD
[Lmite Inferior] as [Lmite Inferior LT Lib],
[Lmite Superior] as [Lmite Superior LT Lib],
Descripcin
as [Rango Tiempo LT Lib]
FROM $(rootQvdsBase)\rangosleadtimes.qvd (qvd);
rangoltLiberacion:
IntervalMatch ([Tiempo Liberacion ODC])
load
[Lmite Inferior LT Lib],
[Lmite Superior LT Lib]
resident rangoltLib;
rangoltFact:
LOAD
[Lmite Inferior] as [Lmite Inferior LT Fact],
[Lmite Superior] as [Lmite Superior LT Fact],
Descripcin
as [Rango Tiempo LT Fact]
FROM $(rootQvdsBase)\rangosleadtimes.qvd (qvd);
rangoltFacturacion:
IntervalMatch ([Tiempo Facturacion])
load
[Lmite Inferior LT Fact],
[Lmite Superior LT Fact]
resident rangoltFact;
rangoltEnt:
LOAD

[Lmite Inferior] as [Lmite Inferior LT Ent],


[Lmite Superior] as [Lmite Superior LT Ent],
Descripcin
as [Rango Tiempo LT Ent]
FROM $(rootQvdsBase)\rangosleadtimes.qvd (qvd);
rangoltEntrega:
IntervalMatch ([Tiempo Entrega])
load
[Lmite Inferior LT Ent],
[Lmite Superior LT Ent]
resident rangoltEnt;
rangoltTot:
LOAD
[Lmite Inferior] as [Lmite Inferior LT Tot],
[Lmite Superior] as [Lmite Superior LT Tot],
Descripcin
as [Rango Tiempo LT Tot]
FROM $(rootQvdsBase)\rangosleadtimes.qvd (qvd);
rangoltTotal:
IntervalMatch ([Tiempo Proceso])
load
[Lmite Inferior LT Tot],
[Lmite Superior LT Tot]
resident rangoltTot;

DatosTransportes:
LOAD
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo Material],
[Nmero Transporte],Patente)
as keyTransportes,
[Poblacin]
as [Poblacin Destino],
[Provincia destinat. mcas.],
[Nmero Viaje],
//
[Fe.contabilizacin]
as FechaTransportes,
[Peso neto por etapa],
[Peso neto por etapa]
as [Cantidad Despachada]
FROM $(rootQvdsIntermedio)\DatosTransportesFinal.qvd (qvd);
LEFT JOIN
LOAD
[Nmero Viaje],
count(distinct [Nmero Cliente]) as [Cant. Clientes]
FROM $(rootQvdsIntermedio)\DatosTransportesFinal.qvd (qvd)
GROUP BY [Nmero Viaje];
rangoclientes:
LOAD
[Lmite Inferior] as [Lmite Inferior Clientes],
[Lmite Superior] as [Lmite Superior Clientes],
Descripcin
as [Rango Cantidad Clientes]
FROM $(rootQvdsBase)\rangosclientes.qvd (qvd);
rangoCantClientes:
IntervalMatch ([Cant. Clientes])
load
[Lmite Inferior Clientes],
[Lmite Superior Clientes]
resident rangoclientes;
/*agregado por pablo*/
LOAD
autonumberhash256(year(Fecha),num(month(Fecha),'00'),num(day(Fecha),'00'),Mate
rial) as keyDespacho,
CantidadTNDespacho as TNDespachadas
FROM $(rootQvdsBase)\despachosTotales.qvd (qvd)
where not Material like '*Resultado total*';

EMPLEADOS:
empleadoslogistica:
LOAD
autonumberhash256(year(Fecha),num(month(Fecha),'00'),num(day(Fecha),'00')) as
keyEmpleados,
[Cantidad Empleados],
CantidadHorasHombre,
CantidadHorasTurno,
Fecha as FechaEmpleados
FROM $(rootQvdsBase)\empleadoslogistica.qvd (qvd);
OBJETIVOS:
Objetivos:
LOAD
autonumberhash256(year(Fecha),num(month(Fecha),'00'),num(day(Fecha),'00'),Clas
ificacion)
as keyObjetivos,
Fecha
as
FechaObjetivo,
Clasificacion
as
ClasificacionObjetivo,
Objetivo
FROM $(rootQvdsBase)\objetivos.qvd (qvd);

BALANZA:
balanzas:
LOAD
autonumberhash256(year([Fecha Salida Ingreso]),num(month([Fecha Salida
Ingreso]),'00'),num(day([Fecha Salida Ingreso]),'00'),[Hora de Entrada
Ingreso],[Patente Camin]) as keyBalanzaIngreso,
[Hora de Entrada Ingreso],
[Hora de Salida Ingreso],
[Tiempo Total de Espera],
[Tiempo Espera Rango],
[Patente Camin] as [Patente Camin Ingreso],
[Fila Ingreso]
FROM $(rootQvdsIntermedio)\balanzaingreso.qvd (qvd);
balanzaexpedicion:
Concatenate (balanzas)
LOAD
autonumberhash256(year([Fecha Salida Expedicin]),num(month([Fecha
Salida Expedicin]),'00'),num(day([Fecha Salida Expedicin]),'00'),[Hora de
Entrada Expedicin],[Patente Camin]) as keyBalanzaIngreso,
[Fecha Entrada Expedicin],
[Hora de Entrada Expedicin],
[Hora de Salida Expedicin],
[Tiempo Total Operativo],
[Tiempo Operativo Rango],
[Patente Camin] as [Patente Camin Expedicion],
[Fila Expedicin]
FROM $(rootQvdsIntermedio)\balanzatmpexpedicion.qvd (qvd);
rangobalanzaexpedicion:
LOAD
[Lmite Inferior] as [Lmite Inferior Expedicin],
[Lmite Superior] as [Lmite Superior Expedicin],
Descripcin
as [Rango Tiempo Operativo]
FROM $(rootQvdsBase)\rangosbalanza.qvd (qvd);

intervalrangoexpedicion:
IntervalMatch ([Tiempo Operativo Rango]) load [Lmite Inferior Expedicin],
[Lmite Superior Expedicin] resident rangobalanzaexpedicion;
rangobalanzaingreso:
LOAD
[Lmite Inferior] as [Lmite Inferior Ingreso],
[Lmite Superior] as [Lmite Superior Ingreso],
Descripcin
as [Rango Tiempo Espera]
FROM $(rootQvdsBase)\rangosbalanza.qvd (qvd);
intervalrangoingreso:
IntervalMatch ([Tiempo Espera Rango]) load [Lmite Inferior Ingreso], [Lmite
Superior Ingreso] resident rangobalanzaingreso;

CARTERA:
pedidos:
LOAD
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo
Material],GVen) as keyPedido,
[Fecha de Entrega] as [Fecha Entrega Pedido],
[Fecha de Pedido],
Fecha
as FechaFotoPedido,
Incot,
[Cantidad de pedido],
Fila as FilaPedido,
[Clasificacin Cartera Pedidos]
FROM $(rootQvdsIntermedio)\PedidosClasificadosCartera.qvd (qvd);
odc:
LOAD
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo
Material],GVen) as keyOdc,
//
[Nro ODC],
[Fecha de Entrega] as [Fecha de Entrega ODC],
[Fecha Orden Carga],
Fecha
as FechaFotoOdc,
[Cantidad entrega],
[Status ODC],
Status,
[Clasificacin Material ODC],
Fila as FilaOdc,
[Clasificacin Cartera Odc]
FROM $(rootQvdsIntermedio)\OdcClasificada.qvd (qvd);
FacturacionAcumulada:
LOAD
AutoNumberHash256(year(FechaAcumular),num(month(FechaAcumular),'00'),num(day(F
echaAcumular),'00'),
[Nmero Cliente],[Cdigo Material])
as keyFacAcum,
TotalAcumulado
FROM $(rootQvdsIntermedio)\FacturacionAcumulada.qvd (qvd);

MASTER TABLE:
mastertmp:
//Agregado por Pablo Vaca el 24/05/2011
LOAD
year(FechaAcumular)
as Ao,
num(month(FechaAcumular),'00')
as NumMes,
num(day(FechaAcumular),'00')
as NumDia,

FechaAcumular
as Fecha,
null()
as Hora,
null()
as GVen,
null()
as Clasificacin,
[Nmero Cliente],
[Cdigo Material],
null()
as [Nmero
Transporte],
null()
as [Patente
Camin],
num#(null())
as [Nro ODC],
NULL()
AS [Posicin ODC]
FROM $(rootQvdsIntermedio)\FacturacionAcumulada.qvd (qvd);
LOAD
year([Fecha Salida Ingreso])
as Ao,
num(month([Fecha Salida Ingreso]),'00') as NumMes,
num(day([Fecha Salida Ingreso]),'00') as NumDia,
[Fecha Salida Ingreso]
as Fecha,
[Hora de Entrada Ingreso]
as Hora,
null()
as GVen,
null()
as
Clasificacin,
null()
as [Nmero Cliente],
null()
as [Cdigo Material],
null()
as [Nmero
Transporte],
[Patente Camin]
as [Patente Camin],
num#(null())
as [Nro ODC],
NULL()
AS
[Posicin ODC]
FROM $(rootQvdsIntermedio)\balanzaingreso.qvd (qvd);
LOAD
year([Fecha Salida Expedicin])
as Ao,
num(month([Fecha Salida Expedicin]),'00')
as NumMes,
num(day([Fecha Salida Expedicin]),'00')
as NumDia,
[Fecha Salida Expedicin]
as Fecha,
[Hora de Entrada Expedicin]
as Hora,
null()
as GVen,
null()
as
Clasificacin,
null()
as [Nmero Cliente],
null()
as [Cdigo Material],
null()
as [Nmero
Transporte],
[Patente Camin]
as [Patente Camin],
num#(null())
as [Nro ODC],
NULL()
AS
[Posicin ODC]
FROM $(rootQvdsIntermedio)\balanzatmpexpedicion.qvd (qvd);
//fin del agregado
LOAD
Ao,
NumMes,
NumDia,
FFO
as Fecha,
null()
as Hora,
null()
as GVen,
null()
as Clasificacin,
[Nmero Cliente],
[Cdigo Material],
[Nmero Transporte],
[Patente Camin],
num#([Nro ODC])
as [Nro ODC],
[Posicin ODC]
FROM $(rootQvdsIntermedio)\TiemposProcesos.qvd (qvd);

LOAD
Ao,
NumMes,
NumDia,
Fecha,
null()
as Hora,
GVen,
Clasificacin,
[Nmero Cliente],
[Cdigo Material],
null()
as [Nmero Transporte],
null()
as [Patente Camin],
num#(null())
as [Nro ODC],
NULL()
AS [Posicin ODC]
//FROM $(rootQvdsIntermedio)\PedidosReducida.qvd (qvd);
FROM $(rootQvdsIntermedio)\PedidosClasificadosCartera.qvd (qvd);
LOAD
Ao,
NumMes,
NumDia,
Fecha,
null()
as Hora,
GVen,
Clasificacin,
[Nmero Cliente],
[Cdigo Material],
null()
as [Nmero Transporte],
null()
as [Patente Camin],
num#(null())
as [Nro ODC],
NULL()
AS [Posicin ODC]
FROM $(rootQvdsIntermedio)\OdcClasificada.qvd (qvd);
LOAD
Ao,
NumMes,
NumDia,
Fe.contabilizacin
as Fecha,
null()
as Hora,
null()
as GVen,
null()
as Clasificacin,
[Nmero Cliente],
[Cdigo Material],
[Nmero Transporte],
Patente
as [Patente Camin],
num#(null())
as [Nro ODC],
NULL()
AS [Posicin ODC]
FROM $(rootQvdsIntermedio)\DatosTransportesFinal.qvd (qvd);
LOAD year(Fecha)
as Ao,
num(month(Fecha),'00')
as NumMes,
num(day(Fecha),'00')
as NumDia,
Fecha,
null()
as Hora,
null()
as
null()
as
null()
as [Nmero Cliente],
Material
as [Cdigo Material],
null()
as
Transporte],
null()
as
Camin],
num#(null())
as [Nro ODC],
NULL()
AS
FROM $(rootQvdsBase)\despachosTotales.qvd (qvd);
left join (mastertmp)

GVen,
Clasificacin,
[Nmero
[Patente
[Posicin ODC]

load
[Cdigo Material],
[Clasificacin Material] as ClasificacionMaterial
FROM $(rootQvdsBase)\materiales.qvd (qvd);
master:
LOAD Distinct
Ao,
NumMes,
NumDia,
Fecha,
Hora,
[Nmero Cliente],
[Cdigo Material],
GVen,
[Nmero Transporte],
[Patente Camin],
[Nro ODC],
[Posicin ODC],
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo Material])
as keyFacAcum,
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo Material],
[Nmero Transporte],
[Patente Camin],[Nro ODC], [Posicin ODC])
as keyDemora,
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo
Material],GVen)
as keyPedido,
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo
Material],GVen)
as keyOdc,
autonumberhash256(Ao,NumMes,NumDia,[Nmero Cliente],[Cdigo Material],
[Nmero Transporte],[Patente Camin])
as keyTransportes,
autonumberhash256(Ao,NumMes,NumDia,Hora,[Patente Camin])
as keyBalanzaIngreso,
autonumberhash256(Ao,NumMes,NumDia)
as keyEmpleados,
autonumberhash256(Ao,NumMes,NumDia,ClasificacionMaterial)
as keyObjetivos,
autonumberhash256(Ao,NumMes,NumDia,[Cdigo Material])
as keyDespacho
resident mastertmp;
drop table mastertmp;

MAESTROS:
materiales:
LOAD DISTINCT
[Familia Material],
[Grupo Material],
[SubGrupo Material],
[Cdigo Material],
[Nombre Material],
[Cdigo Material] & ' - ' & [Nombre Material] as FullNameMaterial
FROM $(rootQvdsBase)\materiales.qvd (qvd);
transportes:
LOAD DISTINCT
[Nmero Transporte],
Patente
as [Patente Camin],
[Nombre Transporte]
FROM $(rootQvdsIntermedio)\DatosTransportesFinal.qvd (qvd);
geografia:
LOAD DISTINCT
[Provincia destinat. mcas.],
Latitud

as latitude,

Longitud
as longitude
FROM $(rootQvdsIntermedio)\DatosTransportesFinal.qvd (qvd);
Clientes:
LOAD DISTINCT
[Nmero Cliente],
[Nombre Cliente],
[Direccion Cliente],
Pas,
[Cdigo postal],
Poblacin
FROM $(rootQvdsBase)\ClientesSAP.qvd (qvd);

as [Poblacin Cliente]

meses:
LOAD * INLINE [
NumMes, Mes
01, Ene
02, Feb
03, Mar
04, Abr
05, May
06, Jun
07, Jul
08, Ago
09, Set
10, Oct
11, Nov
12, Dic
];

MAIN:
SET
SET
SET
SET
SET
SET
SET
SET
SET
SET

ThousandSep='.';
DecimalSep=',';
MoneyThousandSep='.';
MoneyDecimalSep=',';
MoneyFormat='$ #.##0,00;$-#.##0,00';
TimeFormat='hh:mm:ss';
DateFormat='DD/MM/YYYY';
TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';
MonthNames='ene;feb;mar;abr;may;jun;jul;ago;sep;oct;nov;dic';
DayNames='lun;mar;mi;jue;vie;sb;dom';

$(Include=..\config\apl-logistica.ini);

EXPRESIONES:
longitude
=sum( round (256*pow(2,($(var_zoom)-1)))+( longitude *((256*pow(2,$(var_zoom)))/360)) )
latitude
=sum(
((256*pow(2,($(var_zoom)-1)))+((0.5*log((1+(sin((latitude)*pi()/180)))/(1-(sin((latitude)*pi()/180)))))*((256*pow(2,$(var_zoom)))/(2*pi()))))
)

EJE X
MIN ESTATICO:
(256*pow(2,($(var_zoom)-1)))+( var_mid_long
-round(map_size_x/2)

*((256*pow(2,$(var_zoom)))/360))

MAX ESTATICO:
( (256*pow(2,($(var_zoom)-1)))+( var_mid_long
(var_zoom)))/360)) + round(map_size_x/2))

*((256*pow(2,$

EJEY:
MIN ESTATICO:
=((256*pow(2,($(var_zoom)-1)))+((0.5*log((1+(sin(var_mid_lat*pi()/180)))/(1(sin(var_mid_lat*pi()/180)))))*((-256*pow(2,$(var_zoom)))/(2*pi())))
+round(map_size_y/2))
MAXIMO ESTATICO:
=((256*pow(2,($(var_zoom)-1)))+((0.5*log((1+(sin(var_mid_lat*pi()/180)))/(1(sin(var_mid_lat*pi()/180)))))*((-256*pow(2,$(var_zoom)))/(2*pi())))round(map_size_y/2))

='http://maps.google.com/staticmap?center='
&
num(var_mid_lat, '##############', '.', ',' )
&
','
&
num(var_mid_long, '##############', '.', ',' )
&
'&zoom=$(var_zoom)'
&
'&maptype='&var_maptype
&
'&size='&map_size_x&'x'&map_size_y
&
'&key='&gmap_key & '.jpg'