<?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 create new fields automatically using loop for in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/create-new-fields-automatically-using-loop-for/m-p/1770295#M59594</link>
    <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table I want to optimize creating it using a loop for instead of manually. The original table is named Jobchange_Original. The another is the table I'm trying to improve creating automatically the fields that make reference to the line name, e.g. &lt;STRONG&gt;JOBCHANGE_LINE_&lt;EM&gt;LINENAME&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Logistix_0-1608731031359.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46082iD9C8DAB32A95F3C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Logistix_0-1608731031359.png" alt="Logistix_0-1608731031359.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the script to create the original table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;JOBCHANGE_ORIGINAL:

  Load

    LINE_IN_JOBCHANGE AS LINE_IN_JOBCHANGE_JOBCHANGE,
    JOBCHANGE_LINE AS JOBCHANGE_LINE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS11',Fecha_cambio) AS JOBCHANGE_LINE_CS11_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS12',Fecha_cambio) AS JOBCHANGE_LINE_CS12_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS13',Fecha_cambio) AS JOBCHANGE_LINE_CS13_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS20',Fecha_cambio) AS JOBCHANGE_LINE_CS20_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS21',Fecha_cambio) AS JOBCHANGE_LINE_CS21_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS22',Fecha_cambio) AS JOBCHANGE_LINE_CS22_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS23',Fecha_cambio) AS JOBCHANGE_LINE_CS23_DATE_JOBCHANGE,
    JOBCHANGE_LINE&amp;amp;'_'&amp;amp; Turno_cambio	AS LINK_JOBCHANGE_JOBCHANGE
    Resident detail
    Where LINE_IN_JOBCHANGE='1' Order by JOBCHANGE_LINE;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the original table results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Logistix_2-1608731111399.png" style="width: 800px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46084iC201DA2D83FCAF33/image-dimensions/800x88?v=v2" width="800" height="88" role="button" title="Logistix_2-1608731111399.png" alt="Logistix_2-1608731111399.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the script I made to create the same table with less code, the problem is when I comment the left join, It creates different tables for each field and when i do a left/right/inner/outer join (I tried everything) it creates one single table with repeated records. The thing is I don't know how to join all this fields in one single table without repeating records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;JOBCHANGE:
  Load
    LINE_IN_JOBCHANGE,
    JOBCHANGE_LINE
  Resident detail
  Where LINE_IN_JOBCHANGE='1' Order by JOBCHANGE_LINE;
 
for i = 0 to $(nLineas)
	e = $(i)+1;
    
	//left join
    Load
    	IF(JOBCHANGE_LINE='$(vDirector_$(e))',Fecha_cambio) as JOBCHANGE_LINE_$(vDirector_$(e))
    Resident detail
    Where LINE_IN_JOBCHANGE='1' Order by JOBCHANGE_LINE;
Next i; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I get with the second script (with left join uncommented).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Logistix_3-1608731135401.png" style="width: 804px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46085i677B7BABB3876ADC/image-dimensions/804x179?v=v2" width="804" height="179" role="button" title="Logistix_3-1608731135401.png" alt="Logistix_3-1608731135401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 17:40:24 GMT</pubDate>
    <dc:creator>Logistix</dc:creator>
    <dc:date>2024-11-16T17:40:24Z</dc:date>
    <item>
      <title>create new fields automatically using loop for</title>
      <link>https://community.qlik.com/t5/App-Development/create-new-fields-automatically-using-loop-for/m-p/1770295#M59594</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table I want to optimize creating it using a loop for instead of manually. The original table is named Jobchange_Original. The another is the table I'm trying to improve creating automatically the fields that make reference to the line name, e.g. &lt;STRONG&gt;JOBCHANGE_LINE_&lt;EM&gt;LINENAME&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Logistix_0-1608731031359.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46082iD9C8DAB32A95F3C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Logistix_0-1608731031359.png" alt="Logistix_0-1608731031359.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the script to create the original table:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;JOBCHANGE_ORIGINAL:

  Load

    LINE_IN_JOBCHANGE AS LINE_IN_JOBCHANGE_JOBCHANGE,
    JOBCHANGE_LINE AS JOBCHANGE_LINE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS11',Fecha_cambio) AS JOBCHANGE_LINE_CS11_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS12',Fecha_cambio) AS JOBCHANGE_LINE_CS12_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS13',Fecha_cambio) AS JOBCHANGE_LINE_CS13_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS20',Fecha_cambio) AS JOBCHANGE_LINE_CS20_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS21',Fecha_cambio) AS JOBCHANGE_LINE_CS21_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS22',Fecha_cambio) AS JOBCHANGE_LINE_CS22_DATE_JOBCHANGE,
    IF(JOBCHANGE_LINE='CS23',Fecha_cambio) AS JOBCHANGE_LINE_CS23_DATE_JOBCHANGE,
    JOBCHANGE_LINE&amp;amp;'_'&amp;amp; Turno_cambio	AS LINK_JOBCHANGE_JOBCHANGE
    Resident detail
    Where LINE_IN_JOBCHANGE='1' Order by JOBCHANGE_LINE;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the original table results:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Logistix_2-1608731111399.png" style="width: 800px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46084iC201DA2D83FCAF33/image-dimensions/800x88?v=v2" width="800" height="88" role="button" title="Logistix_2-1608731111399.png" alt="Logistix_2-1608731111399.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the script I made to create the same table with less code, the problem is when I comment the left join, It creates different tables for each field and when i do a left/right/inner/outer join (I tried everything) it creates one single table with repeated records. The thing is I don't know how to join all this fields in one single table without repeating records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;JOBCHANGE:
  Load
    LINE_IN_JOBCHANGE,
    JOBCHANGE_LINE
  Resident detail
  Where LINE_IN_JOBCHANGE='1' Order by JOBCHANGE_LINE;
 
for i = 0 to $(nLineas)
	e = $(i)+1;
    
	//left join
    Load
    	IF(JOBCHANGE_LINE='$(vDirector_$(e))',Fecha_cambio) as JOBCHANGE_LINE_$(vDirector_$(e))
    Resident detail
    Where LINE_IN_JOBCHANGE='1' Order by JOBCHANGE_LINE;
Next i; &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I get with the second script (with left join uncommented).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Logistix_3-1608731135401.png" style="width: 804px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/46085i677B7BABB3876ADC/image-dimensions/804x179?v=v2" width="804" height="179" role="button" title="Logistix_3-1608731135401.png" alt="Logistix_3-1608731135401.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 17:40:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/create-new-fields-automatically-using-loop-for/m-p/1770295#M59594</guid>
      <dc:creator>Logistix</dc:creator>
      <dc:date>2024-11-16T17:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: create new fields automatically using loop for</title>
      <link>https://community.qlik.com/t5/App-Development/create-new-fields-automatically-using-loop-for/m-p/1770517#M59614</link>
      <description>&lt;P&gt;By any chance are you trying this?&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptPrefixes/Generic.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/April2020/Subsystems/Client/Content/QV_QlikView/Scripting/ScriptPrefixes/Generic.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Dec 2020 20:22:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/create-new-fields-automatically-using-loop-for/m-p/1770517#M59614</guid>
      <dc:creator>Anil_Babu_Samineni</dc:creator>
      <dc:date>2020-12-25T20:22:44Z</dc:date>
    </item>
  </channel>
</rss>

