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: 
mariam_vd
Contributor II
Contributor II

IntervalMatch does not work

Hello,

Could you please help me to figure out, why this script returns nothing?

The EndTime vqlue is correct, I can see it, but the match doesn´t work

 

LOAD
time(timestamp(DTENDE, 'YYYY-MM-DD hh:mm:ss:fff'),'hh:mm:ss') as EndTime;


[TimeStamps]:

SELECT "DTENDE"
FROM "PJ_VD";


[Shifts]:

LOAD * Inline [
Start, End, Shift
07:00:00, 14:59:59, Shift 1
15:00:00, 22:59:59, Shift 2
23:00:00, 06:59:59, Shift 3
];


//Link the field EndTime to the time intervals defined by the fields Start and End.
Inner Join IntervalMatch (EndTime)
LOAD Start, End
Resident Shifts;

Labels (1)
4 Replies
marksouzacosta

Hi @mariam_vd,

Date and Time always causes some confusion in Qlik.
You have to understand that Qlik basically has two data types: strings and numbers.

Date and Time, or Timestamp values are composed by two numeric parts. An Integer part (date) and the decimals (time).

Time(), Date(), TimeStamp() functions are just format functions, meaning, these functions DON'T change the value of the field, even if it is displayed so.

But, Qlik offers functions that actually change the value of fields. Those are: Time#(), Date#(), TimeStamp#() and other Match functions to extract date and time portions like Floor() and Frac().

So, probably your IntervalMatch is not working because the values are not compatible, so you have to transform the values correctly.

This is how you can manipulate the Date and Time values using Floor and Frac:marksouzacosta_0-1718214568669.png

And this is how you can try to adjust your Load Script to convert correctly the values.
Please note that I don't know your database values so I'm assuming it is a Date and Time field.

 

 

 

[TimeStamps]:
LOAD
	"DTENDE" AS SourceEndDateTime,
    Date(Floor("DTENDE")) AS EnDate, // Floor changes the value, Date visually format the value
    Time(Frac("DTENDE")) AS EnTime // Frac changes the value, Time visually format the value
;
SELECT
	"DTENDE"
FROM
	"PJ_VD"
;


[Shifts]:
LOAD
// Use these functions, just in case
Time#(Start,'hh:mm:ss') AS Start, // Time# convert the value
Time#(End,'hh:mm:ss') AS End, // Time# convert the value
Shift
Inline [
Start, End, Shift
07:00:00, 14:59:59, Shift 1
15:00:00, 22:59:59, Shift 2
23:00:00, 06:59:59, Shift 3
];

//Link the field EndTime to the time intervals defined by the fields Start and End.
Inner Join IntervalMatch (EndTime)
LOAD Start, End
Resident Shifts;

 

 

 

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Your Start and End fields are just times -- fractions of a day. Your EndTime field is a full timestamp, integer date + time fraction. I believe you will want to modify your EndTime load to exclude the date portion.

time(frac(timestamp(DTENDE, 'YYYY-MM-DD hh:mm:ss:fff')),'hh:mm:ss') as EndTime;

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

mariam_vd
Contributor II
Contributor II
Author

@rwunderlich @marksouzacosta