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

Optimisation des intervalles de dates

Bonjour,

je veux transformer le premier tableau au deuxième. C'est à dire si temps_travail et  du deuxième ligne = temps_travail et motif du 3eme ligne alors je les mets dans une seule ligne avec debut_occupation = min(debut_occupat) et fin_occupation.

Merci.

test.png

12 Replies
chadliagabsi
Creator II
Creator II
Author

Morning Allu Allu,

i'm trying your script, It does'nt work.

carpentiere
Contributor II
Contributor II

Bonjour,

Pour le cas précédent, voici comment je procéderais :

INIT:

LOAD * INLINE [

    Matricule, Motif, Debut, Fin, Duree

    876, Avancement minimum, 03/05/2007, 30/11/2007, 100

    876, Renouvellement, 01/12/2007, 30/11/2007, 100

    876, Renouvellement, 01/12/2007, 30/11/2008, 100

    876, Renouvellement, 01/12/2007, 30/11/2009, 100   

    518, CDD, 12/12/2005, 13/08/2006

    518, CDD, 12/08/2007, 13/08/2008

];



RESULTAT:

NoConcatenate

LOAD Matricule,Motif,Debut,max(Date(Fin)) as Fin ,Duree Resident INIT Group by Matricule,Motif,Debut,Duree;


On obitent bien dans la table résultat 4 lignes sur les 6 initiales.

Cdlt,

carpentiere
Contributor II
Contributor II

Concernant ce second point voici mon code  pour passer de ce tableau

1.JPG

a ce tableau

2.JPG

INIT:

LOAD * INLINE [

    Matricule, Motif, Debut, Fin, Duree

    876, Avancement minimum, 03/05/2007, 30/11/2007, 100

    876, Renouvellement, 01/11/2007, 30/11/2007, 100

    876, Renouvellement, 01/12/2007, 30/11/2008, 100

    876, Renouvellement, 01/12/2008, 30/11/2009, 100   

    518, CDD, 12/12/2005, 13/08/2006

    518, CDD, 12/08/2007, 13/08/2008

];



QUALIFY *;

BASE:

LOAD * Resident INIT;


////////////////

Set boucle = 1;


do WHILE (boucle<>0)

QUALIFY *;

T1:

LOAD *,Date(Debut)+0 as JourDebut, Date(Fin)+0 as JourFin, Date(Fin)+1 as JourSuivant Resident INIT;

UNQUALIFY *;

T2:

NoConcatenate

LOAD *,Date(Debut)+0 as JourDebut, Date(Fin)+0 as JourFin, Date(Fin)+1 as JourSuivant Resident INIT;

RESULTAT:

Left Join (T2) LOAD T1.Debut,T1.Fin,T1.Matricule as Matricule,T1.Motif as Motif,T1.Duree as Duree, T1.JourSuivant as JourDebut Resident T1;

DROP Table T1;

DROP Table INIT;

INIT:

NoConcatenate

LOAD Matricule

,Motif

,if(Isnull(T1.Debut),Debut,T1.Debut) as Debut

,Fin

,Duree

,if(IsNull(T1.Debut),0,1) as Indicateur

,T1.Debut

Resident T2;

DROP table T2;


TMP:

NoConcatenate

LOAD max(Indicateur) as aRefaire Resident INIT;

LET a = FieldValue('aRefaire', 1);

LET boucle = a;

Drop table TMP;

drop Fields Indicateur,T1.Debut;


Loop 


// On regroupe

///////////////////////

UNQUALIFY *;

RESULTAT:

NoConcatenate

LOAD Matricule,Motif,Debut,max(Date(Fin)) as Fin ,Duree Resident INIT Group by Matricule,Motif,Debut,Duree;



DROP Table INIT;

RENAME Table RESULTAT to INIT;