Last active
January 17, 2017 16:03
-
-
Save fcojperez/cf8b2767147423e8c111 to your computer and use it in GitHub Desktop.
Script para Qlikview para la generación de un sencillo master calendar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TRACE ***************************; | |
TRACE * PROCEDIMIENTOS *; | |
TRACE ***************************; | |
/** | |
* CREA MASTER CALENDARIO | |
* pCampoFecha: Campo Fecha que utilizaremos para calcular el máximo y el mínimo del master calendar | |
* pTablaCampoFecha: Tabla que contiene el campo [pCampoFecha] | |
* Basado en el Script para Master Calendar del libro Qlikview Developer 11 | |
* https://www.packtpub.com/big-data-and-business-intelligence/qlikview-11-developers | |
*/ | |
TRACE crear_master_calendar; | |
SUB crear_master_calendar(pCampoFecha, pTablaCampoFecha) | |
QUALIFY *; | |
Temp_Calendar_Range: | |
LOAD | |
max($(pCampoFecha)) as MaxDate, | |
min($(pCampoFecha)) as MinDate | |
Resident $(pTablaCampoFecha); | |
UNQUALIFY *; | |
//Asignacion de rango a variables | |
LET vMinDate = Peek('Temp_Calendar_Range.MinDate', 0, 'Temp_Calendar_Range'); | |
LET vMaxDate = Peek('Temp_Calendar_Range.MaxDate', 0, 'Temp_Calendar_Range'); | |
DROP TABLE Temp_Calendar_Range; | |
master_calendar: | |
LOAD Distinct | |
Year(Date(Temp_Date, 'DD/MM/YYYY'))*10000 + Month(Date(Temp_Date, 'DD/MM/YYYY'))*100 + Day(Date(Temp_Date, 'DD/MM/YYYY')) AS calendario_ID, | |
Date(Temp_Date, 'DD/MM/YYYY') as [Fecha], | |
Year(Temp_Date) as [Año], | |
Month(Temp_Date) as [Mes] | |
; | |
LOAD DISTINCT | |
DayStart($(vMinDate) + IterNo() - 1) as Temp_Date | |
AutoGenerate(1) | |
WHILE $(vMinDate) + IterNo() -1 <= $(vMaxDate); | |
LET vMaxDate = null(); | |
LET vMinDate = null(); | |
END SUB; | |
TRACE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment