Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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éro | Nom | Prénom |
---|---|---|
46 | MARTIN | Michel |
46 | DUPOND | Marc |
46 | SMITH | Paul |
55 | WICK | John |
56 | JACK | Daniel |
56 | BLEUTON | Laurie |
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éro | Individu 1 | Individu 2 | Individu 3 | Individu 4 | |
---|---|---|---|---|---|
46 | MARTIN Michel | DUPOND Marc | SMITH Paul | Null | |
55 | SMITH John | Null | Null | Null | |
56 | JACK Daniel | BLEUTON Laurie | Null | Null |
Est-ce possible via Qlikview ? Et surtout comment faire ? Peut-on le faire dans le script directement ?
Merci par avance,
Cdlt,
RESULT:
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;
RESULT:
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;
oui mais I don't think there is an error (no error when I reload)
maxgro,
En effet, l'erreur n'est pas bloquante. Après rechargement, l'exemple fonctionne parfaitement.
Merci énormément !!
Bonne journée,