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

Regrouper plusieurs lignes en une seule

Bonjour,

J'ai une requête complexe (avec 3 jointures et un distinct) qui me permet d'afficher un résultat de cette forme :

NuméroNomPrénom
46MARTINMichel
46DUPONDMarc
46SMITHPaul
55WICKJohn
56JACKDaniel
56BLEUTONLaurie

Mon problème : j'obtiens plusieurs lignes pour le même Numéro.

(Ce qui est normal pour le domaine étudié mais le boss voudrait un affichage différent.)

Par exemple : 3 lignes pour le Numéro 46.

Je cherche à en obtenir un résultat de cette forme là :

NuméroIndividu 1Individu 2Individu 3Individu 4
46MARTIN MichelDUPOND MarcSMITH PaulNull
55SMITH JohnNullNullNull
56JACK DanielBLEUTON LaurieNullNull

Est-ce possible via Qlikview ? Et surtout comment faire ? Peut-on le faire dans le script directement ?

Merci par avance,

Cdlt,

1 Solution

Accepted Solutions
maxgro
MVP
MVP

RESULT:

1.png

SCRIPT:

source:

LOAD

  AutoNumber(Numéro) as id,

  Numéro,

    Nom,

    Prénom,

    Nom & ' ' & Prénom as NomPrenom

FROM

[https://community.qlik.com/thread/180374]

(html, codepage is 1252, embedded labels, table is @1);

source2:

LOAD

  Numéro,

    Nom,

    Prénom,

    NomPrenom,

    if(Numéro<>Peek(Numéro),1, Peek(No)+1) as No

Resident source;

DROP Table source;

tmp:

load max(f1) as MaxNumOfNomPrenom;

load

  Numéro,

  count(DISTINCT NomPrenom) as f1

Resident source2

Group By Numéro;

let vMax=Peek('MaxNumOfNomPrenom');

trace vMax=$(vMax);

DROP Table tmp;

let vjoin = 'final: ';

for i=1 to $(vMax)

  $(vjoin)

  load

  Numéro,

     NomPrenom as NomPrenom_$(i)

  Resident source2 

  Where No = $(i);

  let vjoin=' join (final) ';

NEXT;

DROP Table source2;

View solution in original post

4 Replies
maxgro
MVP
MVP

RESULT:

1.png

SCRIPT:

source:

LOAD

  AutoNumber(Numéro) as id,

  Numéro,

    Nom,

    Prénom,

    Nom & ' ' & Prénom as NomPrenom

FROM

[https://community.qlik.com/thread/180374]

(html, codepage is 1252, embedded labels, table is @1);

source2:

LOAD

  Numéro,

    Nom,

    Prénom,

    NomPrenom,

    if(Numéro<>Peek(Numéro),1, Peek(No)+1) as No

Resident source;

DROP Table source;

tmp:

load max(f1) as MaxNumOfNomPrenom;

load

  Numéro,

  count(DISTINCT NomPrenom) as f1

Resident source2

Group By Numéro;

let vMax=Peek('MaxNumOfNomPrenom');

trace vMax=$(vMax);

DROP Table tmp;

let vjoin = 'final: ';

for i=1 to $(vMax)

  $(vjoin)

  load

  Numéro,

     NomPrenom as NomPrenom_$(i)

  Resident source2 

  Where No = $(i);

  let vjoin=' join (final) ';

NEXT;

DROP Table source2;

Not applicable
Author

Hello maxgro,

Can you link me the .qvw ? There is an error in the Script part near i=1 to $(vMax)


QV56.PNG

maxgro
MVP
MVP

oui mais I don't think there is an error (no error when I reload)

Not applicable
Author

maxgro,

En effet, l'erreur n'est pas bloquante. Après rechargement, l'exemple fonctionne parfaitement.

Merci énormément !! 

Bonne journée,