<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to load a new table from existing one using for each loop when the source table? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736560#M56320</link>
    <description>&lt;P&gt;Output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV69.PNG" style="width: 648px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39159i48F1D80F77A99621/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV69.PNG" alt="commQV69.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 18 Aug 2020 02:32:16 GMT</pubDate>
    <dc:creator>Saravanan_Desingh</dc:creator>
    <dc:date>2020-08-18T02:32:16Z</dc:date>
    <item>
      <title>How to load a new table from existing one using for each loop when the source table?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736458#M56311</link>
      <description>&lt;P&gt;I have a table with the following structure:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KCD2O.png" style="width: 324px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39125iA147EF58DF4B6FA6/image-size/large?v=v2&amp;amp;px=999" role="button" title="KCD2O.png" alt="KCD2O.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The desired loaded table in `Qlik Sense` is as following:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RyVLF.png" style="width: 296px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39126iFAAF6122ED0F7AE1/image-size/large?v=v2&amp;amp;px=999" role="button" title="RyVLF.png" alt="RyVLF.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;BY this structure, I will be able to add a table showing each doctor, and how many medications he prescribed, and even break it down into detailed pivot table to show what are these meds:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="oxeDx.png" style="width: 313px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39127i00C44863A9861782/image-size/large?v=v2&amp;amp;px=999" role="button" title="oxeDx.png" alt="oxeDx.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I tried to loop over the initial table `[Medications]` (which is coming from a REST API, so we cannot change it before loading to desired form):&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FOR Each ev in FieldValueList('Event')&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;[MedAndDoctors]:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;LOAD &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;$(ev) as event_id,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (Field = 'Medication1' OR Field=Medication2 OR Field = Medication3 OR..., [Field]) AS med_name,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (Field = 'Doctor', [Field]) AS doctor_name,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if (Field = 'Medication1 Quantity' OR Field = 'Medication2 Quantity' OR ..., [Field]) AS Quantity&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;RESIDENT ([Medications]);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;WHERE event_id = '$(ev)';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Next ev;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Note that `Field` column contains lots of more info. Actually, the survey filled, is saved in a vertical structure, instead of the regular horizontal structure where all values of each event are on the same row.&lt;/P&gt;&lt;P&gt;The result was exactly the same of `[Medications]` table but with only the specified field values, so I couldn't display the desired output table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 17:14:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736458#M56311</guid>
      <dc:creator>im_officer</dc:creator>
      <dc:date>2020-08-17T17:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to load a new table from existing one using for each loop when the source table?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736533#M56315</link>
      <description>&lt;P&gt;One solution is.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tab1:
LOAD * INLINE [
    Event, Field, Value of the Field
    Ev1, Medication1, TRUE
    Ev1, Medication2, TRUE
    Ev1, Doctor, XYZ
    Ev1, Medication1 Quantity, 13
    Ev1, Medication2 Quantity, 3
    Ev2, Medication1, TRUE
    Ev2, Doctor, ABC
    Ev2, Medication1 Quantity, 5
];

Gen:
Generic
LOAD Event, 'Medication (TRUE)', Field
Resident tab1
Where Field Like 'Medication*' And Not Field Like '*Quantity' And [Value of the Field]='TRUE';

Gen:
Generic
LOAD Event, 'Quantity', [Value of the Field]
Resident tab1
Where Field Like 'Medication*' And Field Like '*Quantity';

Gen:
Generic
LOAD Event, 'Doctor', [Value of the Field]
Resident tab1
Where Field = 'Doctor';

Drop Table tab1;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Aug 2020 23:17:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736533#M56315</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-08-17T23:17:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to load a new table from existing one using for each loop when the source table?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736535#M56316</link>
      <description>&lt;P&gt;Output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV68.PNG" style="width: 643px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39153iBA849B7426352C98/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV68.PNG" alt="commQV68.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2020 23:18:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736535#M56316</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-08-17T23:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to load a new table from existing one using for each loop when the source table?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736558#M56319</link>
      <description>&lt;P&gt;With a small fix.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;tab1:
LOAD * INLINE [
    Event, Field, Value of the Field
    Ev1, Medication1, TRUE
    Ev1, Medication2, TRUE
    Ev1, Doctor, XYZ
    Ev1, Medication1 Quantity, 13
    Ev1, Medication2 Quantity, 3
    Ev2, Medication1, TRUE
    Ev2, Doctor, ABC
    Ev2, Medication1 Quantity, 5
];

Gen:
Generic
LOAD Event, 'Medication (TRUE)', Field
Resident tab1
Where Field Like 'Medication*' And Not Field Like '*Quantity' And [Value of the Field]='TRUE';

Gen:
Generic
LOAD Event, SubField(Field,' ',1) As [Medication (TRUE)],'Quantity', [Value of the Field]
Resident tab1
Where Field Like 'Medication*' And Field Like '*Quantity';

Gen:
Generic
LOAD Event, 'Doctor', [Value of the Field]
Resident tab1
Where Field = 'Doctor';

Drop Table tab1;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 18 Aug 2020 02:30:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736558#M56319</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-08-18T02:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to load a new table from existing one using for each loop when the source table?</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736560#M56320</link>
      <description>&lt;P&gt;Output.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="commQV69.PNG" style="width: 648px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/39159i48F1D80F77A99621/image-size/large?v=v2&amp;amp;px=999" role="button" title="commQV69.PNG" alt="commQV69.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2020 02:32:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-load-a-new-table-from-existing-one-using-for-each-loop/m-p/1736560#M56320</guid>
      <dc:creator>Saravanan_Desingh</dc:creator>
      <dc:date>2020-08-18T02:32:16Z</dc:date>
    </item>
  </channel>
</rss>

