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

Group by Interval Time

Good morning,

I have a question concerning to Interval time.

I have a table of consume like this:

SupplierFecha
A01/01/2020 03:45
A01/01/2020 05:30
B01/01/2020 06:56
A01/01/2020 09:00
A01/01/2020 10:34
B01/01/2020 11:23

What I pretend is a table like this:

SupplierFromTo
A01/01/2020 03:4501/01/2020 06:56
B01/01/2020 06:5601/01/2020 09:00
A01/01/2020 09:0001/01/2020 11:23
B01/01/2020 11:23 .......

I imagine the solution will be with intervalmatch, but I can not solve this grouping.

Thanks in advance.

 

Labels (1)
5 Replies
Taoufiq_Zarra

what is the rule for choosing to and from ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
sunny_talwar

May be this

 

Table:
LOAD * INLINE [
    Supplier, Fecha
    A, 01/01/2020 03:45
    A, 01/01/2020 05:30
    B, 01/01/2020 06:56
    A, 01/01/2020 09:00
    A, 01/01/2020 10:34
    B, 01/01/2020 11:23
];

tmpTable:
LOAD DISTINCT Supplier,
	 If(Supplier = Previous(Supplier), Previous(Fecha), Fecha) as From
Resident Table
Order By Fecha;

Table:
LOAD DISTINCT Supplier,
	 From,
	 Alt(Peek('From'), '12/31/9999 11:59') as To
Resident tmpTable
Order By From Desc;

DROP Table Table, tmpTable;

 

Brett_Bleess
Former Employee
Former Employee

Did Sunny's example get you what you needed?  If so, please do not forget to return to your thread and use the Accept as Solution button on his post if so, that gives him credit for the assistance and it also lets the other Community Members know it did work too.  If you still need further help, leave an update post.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.
Saravanan_Desingh

One solution is.

tab1:
LOAD *, If(Peek('Supplier')=Supplier, Peek('K1'), RangeSum(Peek('K1'),1)) As K1
	  ,	Peek('K1') As K2
;
LOAD Supplier, Timestamp#(Fecha,'M/D/YYYY hh:mm') As Fecha INLINE [
    Supplier, Fecha
    A, 1/1/2020 3:45
    A, 1/1/2020 5:30
    B, 1/1/2020 6:56
    A, 1/1/2020 9:00
    A, 1/1/2020 10:34
    B, 1/1/2020 11:23
];

Left Join (tab1)
LOAD K1, TimeStamp(Min(Fecha)) As From
Resident tab1
Group By K1
;

tab2:
LOAD K2, TimeStamp(Max(Fecha)) As To
Resident tab1
Group By K2
;

Left Join(tab1)
LOAD K2 As K1, To 
Resident tab2;

Drop Table tab2;
Saravanan_Desingh

commQV63.PNG