Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikTonic
Contributor III
Contributor III

peek fonction ?

Hi,

i need your help please.

for a stay in a hotel i have the following data :

Entry09.07.2020
Exit12.07.2020

 

and 

Presence 
09.07.2020 
09.07.2020 
10.07.2020 
11.07.2020 
12.07.2020 

 

i would like to count 0.5 for the entry date, 0.5 for the exit date and 1 night for the night between entry and exit and 0 if i have several times a presence date.

the result should be :

PresenceNight
09.07.20200.5
09.07.20200
10.07.20201
11.07.20201
12.07.20200.5

 

I wrote :

if (
peek(presence,-1)=presence,0,
if(
presence=exit or presence=entry,0.5,1))) as NightCount,

i obtain :

PresenceResult
09.07.20200.5
09.07.20200.5
10.07.20201
11.07.20201
12.07.20200.5

 

i spent a lot of hour for something probably easy

thanks for your help

 

tonic

1 Solution

Accepted Solutions
MayilVahanan

Hi @QlikTonic 

Try like below

DOCsTemp:
LOAD StayNum,
Entry,
Exit
FROM
[D:\Qlik\Com\Example.xlsx]
(ooxml, embedded labels, table is Stay);

Join
LOAD StayNum,
Presence,
RowNo() as Rows
FROM
[D:\Qlik\Com\Example.xlsx]
(ooxml, embedded labels, table is Presence);


Inner Join(DOCsTemp)
Load Distinct
StayNum
Resident DOCsTemp
Where Presence >= Entry and Presence <= Exit;

Final:
LOAD StayNum, Presence, Entry, Exit, If(Night = Previous(Night) and Night = 0.5, 0, Night) as Night;
Load StayNum, Presence, Entry, Exit, If(Presence = Entry or Presence = Exit, 0.5, 1) as Night Resident DOCsTemp order by StayNum, Presence;

DROP Table DOCsTemp;

o/p:

MayilVahanan_0-1631930654257.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

5 Replies
PrashantSangle

Can you provide sample data?

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
QlikTonic
Contributor III
Contributor III
Author

here you have

thanks

PrashantSangle

Why there is 2 date for entry? & why not for others?

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
MayilVahanan

Hi @QlikTonic 

Try like below

DOCsTemp:
LOAD StayNum,
Entry,
Exit
FROM
[D:\Qlik\Com\Example.xlsx]
(ooxml, embedded labels, table is Stay);

Join
LOAD StayNum,
Presence,
RowNo() as Rows
FROM
[D:\Qlik\Com\Example.xlsx]
(ooxml, embedded labels, table is Presence);


Inner Join(DOCsTemp)
Load Distinct
StayNum
Resident DOCsTemp
Where Presence >= Entry and Presence <= Exit;

Final:
LOAD StayNum, Presence, Entry, Exit, If(Night = Previous(Night) and Night = 0.5, 0, Night) as Night;
Load StayNum, Presence, Entry, Exit, If(Presence = Entry or Presence = Exit, 0.5, 1) as Night Resident DOCsTemp order by StayNum, Presence;

DROP Table DOCsTemp;

o/p:

MayilVahanan_0-1631930654257.png

 

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
QlikTonic
Contributor III
Contributor III
Author

Thanks a lot Mayil!!!!!