Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Perus_Pena
Contributor III
Contributor III

IF - Peek: Why am I getting duplicate rows

Hello,

I have a table with Autonumerate ID as %_KohdeDateID, and Status in field "Huoneiston historia Status".

I'm trying to replace values where status if 'Vapaa' and on the next date it is 'Tarjottu'. I want to overwrite the 'Vapaa' with Tarjottu. And I want to prevent from 'Tarjottu' overwriting all 'Vapaa' Statuses. Only the last one.

 

This is my script:

AH:
NoConcatenate
Load
[%_KohdeDateID],
"Data pvm",
%_KohdeID,
"Huoneiston historia Status",
IF(Match("Huoneiston historia Status", 'Vapaa') and Match(Peek('Huoneiston historia Status'),'Tarjottu'),'Uus tila',"Huoneiston historia Status") as "New - Huoneiston historia Status",
"Huoneiston tila"
Resident AH_TEMP
Order by %_KohdeDateID desc;

The issue is here, I get duplicate rows where the IF statement is true:

 
%_KohdeDateIDData pvmNew - Huoneiston historia StatusHuoneiston historia Status
43711.8.2019VapautumassaVapautumassa
43812.8.2019VapautumassaVapautumassa
43913.8.2019Uus tilaVapaa
43913.8.2019VapaaVapaa
44014.8.2019TarjottuTarjottu
44115.8.2019TarjottuTarjottu
44216.8.2019TarjottuTarjottu
44317.8.2019TarjottuTarjottu
44418.8.2019TarjottuTarjottu
44519.8.2019TarjottuTarjottu
44620.8.2019VapaaVapaa
44721.8.2019Uus tilaVapaa
44721.8.2019VapaaVapaa
44822.8.2019TarjottuTarjottu
44923.8.2019TarjottuTarjottu
45024.8.2019TarjottuTarjottu

 

Regards,

Pena

Labels (3)
12 Replies
Perus_Pena
Contributor III
Contributor III
Author

This should work:

AH_TEMP:
LOAD * Inline [
%_KohdeDateID,'Data pvm','Huoneiston historia Status'
434, 8.8.2019, Vapautumassa
435, 9.8.2019, Vapautumassa
436, 10.8.2019, Vapautumassa
437, 11.8.2019, Vapautumassa
438, 12.8.2019, Vapautumassa
439, 13.8.2019, Vapaa
440, 14.8.2019, Tarjottu
441, 15.8.2019, Tarjottu
442, 16.8.2019, Tarjottu
443, 17.8.2019, Tarjottu
444, 18.8.2019, Tarjottu
445, 19.8.2019, Tarjottu
446, 20.8.2019, Vapaa
447, 21.8.2019, Vapaa
448, 22.8.2019, Tarjottu
449, 23.8.2019, Tarjottu
450, 24.8.2019, Tarjottu
451, 25.8.2019, Tarjottu
452, 26.8.2019, Siirretään sopimukselle
453, 27.8.2019, Sopimuksella ];

Perus_Pena
Contributor III
Contributor III
Author

When I load this from Inline I do not get duplicate rows with the exact same resident load. If i comment away the resident load and drop table I don't have duplicate on these rows. So loading from qvd creates different result than loading from Inline.

Very strange. Haven't been this confused in a while...

Channa
Specialist III
Specialist III

Load
%_KohdeDateID,
[Data pvm],
[Huoneiston historia Status],
If(Match(Peek('Huoneiston historia Status'),'Tarjottu') and "Huoneiston historia Status"='Vapaa' ,'Uus tila',"Huoneiston historia Status")
as "New - Huoneiston historia Status";

 

//if you loading from QVD do order by while loading into QVD on KohdeDateID

LOAD * Inline [
%_KohdeDateID,'Data pvm','Huoneiston historia Status'
434, 8.8.2019, Vapautumassa
435, 9.8.2019, Vapautumassa
436, 10.8.2019, Vapautumassa
437, 11.8.2019, Vapautumassa
438, 12.8.2019, Vapautumassa
439, 13.8.2019, Vapaa
440, 14.8.2019, Tarjottu
441, 15.8.2019, Tarjottu
442, 16.8.2019, Tarjottu
443, 17.8.2019, Tarjottu
444, 18.8.2019, Tarjottu
445, 19.8.2019, Tarjottu
446, 20.8.2019, Vapaa
447, 21.8.2019, Vapaa
448, 22.8.2019, Tarjottu
449, 23.8.2019, Tarjottu
450, 24.8.2019, Tarjottu
451, 25.8.2019, Tarjottu
452, 26.8.2019, Siirretään sopimukselle
453, 27.8.2019, Sopimuksella ];

Channa