Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Data model obviously wrong

Hi,

First of all, I'm new to QlikView, so please excuse my ignorance. Also I'm french, so please excuse my english

I'm trying to load some datas to build some tables. Right now, I'm doing like this (and it's not working, obviously):

[TIRS]:

LOAD

[NUMERO_TIR],

[NUMERO_REFERENCE]

  FROM [lib://Indus/2.0/tirs.csv]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

[METRIQUES]:

LOAD

[NUMERO_TIR],

[METRIQUE],

[VALEUR_METRIQUE]

  FROM [lib://Indus/2.0/metriques.csv]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

NUMERO_TIR is a unique number, and NUMERO_REFERENCE is a number equal to a NUMERO_TIR. It can only be a NUMERO_TIR, not another value.

I would like to import those data and display the following in a table :

METRIQUE | VALEUR_METRIQUE | VALEUR_REFERENCE

It's easy to get METRIQUE and VALEUR_METRIQUE for a NUMERO_TIR, But I can reach to VALEUR_REFERENCE, which is a VALEUR_METRIQUE for another NUMERO_TIR, referenced by NUMERO_REFERENCE.

I'm not sure if I'm clear, let me know if I'm not.

I don't have any unique key in METRIQUES, but I don't think it's the problem. I can't think of another model, can someone give me some advices ?

Damien

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Ok, try this:

[TIRS]:

LOAD NUMERO_TIR,

    NUMERO_REFERENCE

FROM

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

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

[METRIQUES]:

LOAD NUMERO_TIR,

    METRIQUE,

    VALEUR_METRIQUE

FROM

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

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

mapRef:

MAPPING LOAD NUMERO_REFERENCE, NUMERO_TIR RESIDENT TIRS;

LEFT JOIN ([METRIQUES])

LOAD ApplyMap('mapRef',NUMERO_TIR, Null()) AS NUMERO_TIR,    

  METRIQUE,

    VALEUR_METRIQUE AS VALEUR_REFERENCE

FROM

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

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


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Gysbert_Wassenaar

Try this:

[TIRS]:

LOAD

[NUMERO_TIR],

[NUMERO_REFERENCE]

  FROM [lib://Indus/2.0/tirs.csv]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

[METRIQUES]:

LOAD

[NUMERO_TIR],

[METRIQUE],

[VALEUR_METRIQUE]

  FROM [lib://Indus/2.0/metriques.csv]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);

[METRIQUES_REFERENCE]:

LOAD

[NUMERO_TIR] AS [NUMERO_REFERENCE],

[VALEUR_METRIQUE] AS VALEUR_REFERENCE

  FROM [lib://Indus/2.0/metriques.csv]

(txt, codepage is 1252, embedded labels, delimiter is ';', msq);


talk is cheap, supply exceeds demand
Not applicable
Author

By reading your response, I think I may have forgotten an important detail : I have several METRIQUE for a NUMERO_TIR.

Maybe I'll be more clear with example tables :

Table "TIRS"

NUMERO_TIRNUMERO_REFERENCE

1

2
31
41
52
61
72
85
96
105

Table "METRIQUES"

NUMERO_TIRMETRIQUEVALEUR_METRIQUE
1Metric_1Value_1
1Metric_2Value_2
1Metric_3Value_3
1Metric_4Value_4
2Metric_1Value_5
2Metric_5Value_6
3Metric_1Value_7
3Metric_2Value_8
3Metric_3Value_9
3Metric_4Value_10

And eventually, the result I'd like, by selecting a NUMERO_TIR (NUMERO_TIR = 3 in this example) :

METRIQUEVALEUR_METRIQUEVALEUR_REFERENCE
Metric_1Value_7Value_1
Metric_2Value_8Value_2
Metric_3Value_9Value_3
Metric_4Value_10Value_4
ramoncova06
Specialist III
Specialist III

Did you try Gysbert option ?

I am not able to understand on your example the value reference as I do not see that nowhere, is this a calculated field ?

Gysbert_Wassenaar

Ok, try this:

[TIRS]:

LOAD NUMERO_TIR,

    NUMERO_REFERENCE

FROM

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

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

[METRIQUES]:

LOAD NUMERO_TIR,

    METRIQUE,

    VALEUR_METRIQUE

FROM

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

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

mapRef:

MAPPING LOAD NUMERO_REFERENCE, NUMERO_TIR RESIDENT TIRS;

LEFT JOIN ([METRIQUES])

LOAD ApplyMap('mapRef',NUMERO_TIR, Null()) AS NUMERO_TIR,    

  METRIQUE,

    VALEUR_METRIQUE AS VALEUR_REFERENCE

FROM

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

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


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you Gysbert, you were very helpfull !

Damien