Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
129031
Contributor II
Contributor II

Problema con función Peek & If IsNull

Buenas, tengo el siguiente problema, resulta que en mi trabajo me pidieron que de una base de datos levante los datos para verlos en formato tabla, para eso tuve que hacer un Crosstable que me salió bien pero tengo valores nulos en la tabla y tengo que llenar esos datos con la fila de al lado,  lo que no puedo terminar de entender es como usar la función peek para hacer eso, les dejo mi código para que lo vean rápido:

Horas:
CrossTable(semana,horas,3)
LOAD
F1 AS Cliente,
F2 AS Proyecto,
F3 AS Responsable,
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"141",
"15",
"16",
"17",
"18",
"181",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"271",
"28",
"29",
"30",
"31",
"32",
"33",
"34",
"35",
"36",
"361",
"37",
"38",
"39",
"40",
"401",
"41",
"42",
"43",
"44",
"45",
"46",
"47",
"48",
"49",
"491",
"50",
"51",
"52",
"53",
Peek (Proyecto,-1) <<<<<<<<< ACA no se como usar la función para que me levante esos datos, le agradecería mucho la ayuda, gracias!
FROM [lib://Archivos Emanuel/Horas Presupuestadas Proyectos.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Hoja1);

 

Les adjunto la base de datos por si llegaran a necesitarlo para ayudarme.

Labels (6)
1 Solution

Accepted Solutions
QFabian
Specialist III
Specialist III

Hola!, existen las funciones peek() y previous(), son funciones interregistro, pero no la debes usar sobre el mismo load inicial donde ocurre el CrossTable.

Te recomiendo utilizar peek en un primer load, y luego hacer el crosstable utilizando Resident :

 

//primer load
Temp:
Load
IF(isnull(F1), peek(Cliente), F1) as cliente,
IF(isnull(F2), peek(Proyecto), F2) as Proyecto,
F3 AS Responsable,
"1","2","3","4","5","6","7","8","9","10","11","12","13","14","141","15","16","17","18","181",
"19","20","21","22","23","24","25","26","27","271","28","29","30","31","32","33","34","35",
"36","361","37","38","39","40","401","41","42","43","44","45","46","47","48","49","491","50",
"51","52","53"
FROM [lib://Archivos Emanuel/Horas Presupuestadas Proyectos.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Hoja1);

 

//segundo load con el crosstable

Horas:
CrossTable(Semana, Horas,3)
Load
cliente as Cliente,
Proyecto,
Responsable,
"1","2","3","4","5","6","7","8","9","10","11","12","13","14","141","15","16","17","18","181",
"19","20","21","22","23","24","25","26","27","271","28","29","30","31","32","33","34","35",
"36","361","37","38","39","40","401","41","42","43","44","45","46","47","48","49","491","50",
"51","52","53"
Resident Temp;

drop table Temp;

Ojo con los nombres de campo para no eliminar tu tabla con el drop.

Quedo atento!

QFabian

View solution in original post

5 Replies
TiagoCardoso
Creator II
Creator II

Boa noite, tente isso:

 

HorasTEMP:
CrossTable(semana,horas,3)
LOAD
F1 AS Cliente,
F2 AS Proyecto,
F3 AS Responsable,
     [1], 
     [2], 
     [3], 
     [4], 
     [5], 
     [6], 
     [7], 
     [8], 
     [9], 
     [10], 
     [11], 
     [12], 
     [13], 
     [14], 
     [141], 
     [15], 
     [16], 
     [17], 
     [18], 
     [181], 
     [19], 
     [20], 
     [21], 
     [22], 
     [23], 
     [24], 
     [25], 
     [26], 
     [27], 
     [271], 
     [28], 
     [29], 
     [30], 
     [31], 
     [32], 
     [33], 
     [34], 
     [35], 
     [36], 
     [361], 
     [37], 
     [38], 
     [39], 
     [40], 
     [401], 
     [41], 
     [42], 
     [43], 
     [44], 
     [45], 
     [46], 
     [47], 
     [48], 
     [49], 
     [491], 
     [50], 
     [51], 
     [52], 
     [53]     
FROM [lib://Archivos Emanuel/Horas Presupuestadas Proyectos.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Hoja1);

NOCONCATENATE
Horas: 
LOAD 
	Cliente,
	IF(ISNULL(Proyecto),PEEK(Proyecto),Proyecto) AS Proyecto,
	Responsable,
	semana,
	horas
RESIDENT HorasTEMP;

DROP TABLE HorasTEMP;
QFabian
Specialist III
Specialist III

Hola!, existen las funciones peek() y previous(), son funciones interregistro, pero no la debes usar sobre el mismo load inicial donde ocurre el CrossTable.

Te recomiendo utilizar peek en un primer load, y luego hacer el crosstable utilizando Resident :

 

//primer load
Temp:
Load
IF(isnull(F1), peek(Cliente), F1) as cliente,
IF(isnull(F2), peek(Proyecto), F2) as Proyecto,
F3 AS Responsable,
"1","2","3","4","5","6","7","8","9","10","11","12","13","14","141","15","16","17","18","181",
"19","20","21","22","23","24","25","26","27","271","28","29","30","31","32","33","34","35",
"36","361","37","38","39","40","401","41","42","43","44","45","46","47","48","49","491","50",
"51","52","53"
FROM [lib://Archivos Emanuel/Horas Presupuestadas Proyectos.xlsx]
(ooxml, embedded labels, header is 1 lines, table is Hoja1);

 

//segundo load con el crosstable

Horas:
CrossTable(Semana, Horas,3)
Load
cliente as Cliente,
Proyecto,
Responsable,
"1","2","3","4","5","6","7","8","9","10","11","12","13","14","141","15","16","17","18","181",
"19","20","21","22","23","24","25","26","27","271","28","29","30","31","32","33","34","35",
"36","361","37","38","39","40","401","41","42","43","44","45","46","47","48","49","491","50",
"51","52","53"
Resident Temp;

drop table Temp;

Ojo con los nombres de campo para no eliminar tu tabla con el drop.

Quedo atento!

QFabian
129031
Contributor II
Contributor II
Author

Gracias fabian me funciono! muchas gracias me salvaste

QFabian
Specialist III
Specialist III

excelente, pasa por aquí si quieres:

https://community.qlik.com/t5/Qlik-Chile/gh-p/qlik-chile-group

 

QFabian
129031
Contributor II
Contributor II
Author

Fabian, te pido una vez mas de tu ayuda, resulta que ahora quieren ver el mes (que no existe en la base de datos) solo tenemos año (2020) y semana como se ve en el script, estoy pensando en usar esta función pero me tira errores: week(timestamp [, first_week_day [, broken_weeks [, reference_day]]]) otro problema que me surge es que en una semana puede terminar un mes y empezar otro, es difícil de especificar.