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: 
Hamdi_G
Contributor III
Contributor III

Différence groupée par jour et ID

Bonjour, j'aimerais faire une différences d'heures et les classer en fonctions des jours présents dans ma table. La différence devrant se faire exclusivement entre des erreurs inférieures à 600 et celles égales à 607.

1 Solution

Accepted Solutions
Taoufiq_Zarra

Capture.PNGJ'ai modifié l'ancien code avec ça :

 

Datatmp:

LOAD ID, 
     erreur, 
     Timestamp(dates) as dates,
     floor(Date(dates)) as NewDate
FROM
.\donnees_test.xlsx
(ooxml, embedded labels, table is Feuil1);

load distinct NewDate as FNewDate resident Datatmp;

Data:
noconcatenate
load  * resident Datatmp where (erreur <600 or erreur = 607 ) order by ID,dates  ;

drop table Datatmp;



tmp2:
noconcatenate

load *,
if(rowno()=1,0,if(erreur=607,peek(value3),if(previous(erreur)<607,peek(value3),peek(value3)+1))) as value3, 
if(erreur=607 and previous(erreur)=607,1,0) as Flog2 
resident Data;

drop table Data;



tmp3:

load ID,value3,floor(Date(Min(dates))) as NewDate,Timestamp(Max(dates)) as Maxdates,Timestamp(Min(dates)) as Mindates,Time(Timestamp(Max(dates))-Timestamp(Min(dates))) as Interval resident tmp2 where Flog2=0 group by ID,value3;

drop table tmp2;




Final:

load ID ,Date(NewDate) as dates,Time(sum(Interval)) as Cumul resident tmp3  group by ID,NewDate;



drop table tmp3;

 

 

 

Regards,
Taoufiq ZARRA

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

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

View solution in original post

3 Replies
Taoufiq_Zarra

@Hamdi_G 

est ce que tu peux partager aussi un exemple des data et le output ?

Regards,
Taoufiq ZARRA

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

(you can mark up to 3 "solutions") 😉
Hamdi_G
Contributor III
Contributor III
Author

 Ah oui 

Taoufiq_Zarra

Capture.PNGJ'ai modifié l'ancien code avec ça :

 

Datatmp:

LOAD ID, 
     erreur, 
     Timestamp(dates) as dates,
     floor(Date(dates)) as NewDate
FROM
.\donnees_test.xlsx
(ooxml, embedded labels, table is Feuil1);

load distinct NewDate as FNewDate resident Datatmp;

Data:
noconcatenate
load  * resident Datatmp where (erreur <600 or erreur = 607 ) order by ID,dates  ;

drop table Datatmp;



tmp2:
noconcatenate

load *,
if(rowno()=1,0,if(erreur=607,peek(value3),if(previous(erreur)<607,peek(value3),peek(value3)+1))) as value3, 
if(erreur=607 and previous(erreur)=607,1,0) as Flog2 
resident Data;

drop table Data;



tmp3:

load ID,value3,floor(Date(Min(dates))) as NewDate,Timestamp(Max(dates)) as Maxdates,Timestamp(Min(dates)) as Mindates,Time(Timestamp(Max(dates))-Timestamp(Min(dates))) as Interval resident tmp2 where Flog2=0 group by ID,value3;

drop table tmp2;




Final:

load ID ,Date(NewDate) as dates,Time(sum(Interval)) as Cumul resident tmp3  group by ID,NewDate;



drop table tmp3;

 

 

 

Regards,
Taoufiq ZARRA

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

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