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

Concatenation linking seperate records

I have XML files that I convert into QVD files and concatenate together. I've noticed that the top record of one file will be linked to the top record of the other file if they have the same number of questions in the XML header.

The XML structure is below. Questions repeat as well as Patientleveldata and Response.

<DATA_EXPORT>

<HEADER>

      <RECDATE>

            <START></START>

            <END></END>

      </RECDATE>

      <SURVEY_COUNT></SURVEY_COUNT>

      <QUESTION_MAP>

            <QUESTION>

                   <SERVICE></SERVICE>

                  <VARNAME></VARNAME>

                  <QUESTION_TEXT></QUESTION_TEXT>

            </QUESTION>

      </QUESTION_MAP>

</HEADER>

<PATIENTLEVELDATA>

      <SURVEY_ID></SURVEY_ID>

      <CLIENT_ID></CLIENT_ID>

      <SERVICE></SERVICE>

      <RECDATE></RECDATE>

      <DISDATE></DISDATE>

      <ANALYSIS>

            <RESPONSE>

                  <VARNAME></VARNAME>

                  <VALUE></VALUE>

            </RESPONSE>

      </ANALYSIS>

</PATIENTLEVELDATA>

</DATA_EXPORT>

This is how I create the files:

PATIENTLEVELDATA:
LOAD SURVEY_ID,
    CLIENT_ID,
    SERVICE,
    RECDATE,
    DISDATE,
    %Key_PATIENTLEVELDATA_E1A59225A73AF151    // Key for this table: DATA_EXPORT/PATIENTLEVELDATA


FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA]);

CONCATENATE (PATIENTLEVELDATA) LOAD * FROM PATIENTLEVELDATA_14.QVD (qvd);
STORE PATIENTLEVELDATA INTO PATIENTLEVELDATA_14.QVD;


ANALYSIS:
LOAD SERVICE,
    VARNAME,
'ANALYSIS' As CommentType,
    QUESTION_TEXT,
    %Key_HEADER_8B8B72D6FCC98357    // Key to parent table: DATA_EXPORT/HEADER
FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/HEADER/QUESTION_MAP/QUESTION]);

Join (ANALYSIS)
LOAD VARNAME,
'ANALYSIS' As CommentType,
    VALUE,
    %Key_PATIENTLEVELDATA_E1A59225A73AF151    // Key to parent table: DATA_EXPORT/PATIENTLEVELDATA
FROM $(FILE) (XmlSimple, Table is [DATA_EXPORT/PATIENTLEVELDATA/ANALYSIS/RESPONSE]);

CONCATENATE (ANALYSIS) LOAD * FROM ANALYSIS_14.QVD (qvd);
STORE ANALYSIS INTO ANALYSIS_14.QVD;

And this is how I load the files. So if each file has the same number of questions it will select the data of the top record of each file when either one is selected. If the number of questions differ there isn't any linking at all. Now since I have 20 or so XML files I'll have a handful of records that are joined to another record where it really shouldn't. I obviously am not concatinating correctly but it's not really clear to me how or why the number of questions would matter. Any ideas?

PATIENTLEVELDATA:
LOAD SURVEY_ID,
    CLIENT_ID,
    SERVICE,
    RECDATE,
    DISDATE,
    %Key_PATIENTLEVELDATA_E1A59225A73AF151    // Key for this table: DATA_EXPORT/PATIENTLEVELDATA
FROM $(PATIENTLEVELDATA) (qvd);

ANALYSIS:
LOAD SERVICE,
    VARNAME,
    QUESTION_TEXT,
    VALUE,
    %Key_PATIENTLEVELDATA_E1A59225A73AF151
FROM $(ANALYSIS) (qvd);

0 Replies