<?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 Convert Field Contents into Separate Fields (Flags Y/N) in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Convert-Field-Contents-into-Separate-Fields-Flags-Y-N/m-p/2551066#M110438</link>
    <description>&lt;P&gt;I have data with two columns (example below). One is a part number and the other is an agency name.&lt;/P&gt;&lt;P&gt;What I need is to create a table with a field for part number and separate fields to be flagged "Y/N" or "1/0" if that part aligns with that Agency. So if there were 10 Agencies in total, I would have 11 fields in the new table.&lt;/P&gt;&lt;P&gt;The number and content of the Agency field is dynamic. The only time Agency will be NULL is if that part is not associated with any agencies.&lt;/P&gt;&lt;P&gt;I'm hitting a wall with how to accomplish this. Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PART&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AGENCY&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Company1&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Company4&lt;/P&gt;&lt;P&gt;345&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NULL&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Company1&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Company3&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jun 2026 18:42:49 GMT</pubDate>
    <dc:creator>SDT</dc:creator>
    <dc:date>2026-06-10T18:42:49Z</dc:date>
    <item>
      <title>Convert Field Contents into Separate Fields (Flags Y/N)</title>
      <link>https://community.qlik.com/t5/App-Development/Convert-Field-Contents-into-Separate-Fields-Flags-Y-N/m-p/2551066#M110438</link>
      <description>&lt;P&gt;I have data with two columns (example below). One is a part number and the other is an agency name.&lt;/P&gt;&lt;P&gt;What I need is to create a table with a field for part number and separate fields to be flagged "Y/N" or "1/0" if that part aligns with that Agency. So if there were 10 Agencies in total, I would have 11 fields in the new table.&lt;/P&gt;&lt;P&gt;The number and content of the Agency field is dynamic. The only time Agency will be NULL is if that part is not associated with any agencies.&lt;/P&gt;&lt;P&gt;I'm hitting a wall with how to accomplish this. Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PART&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; AGENCY&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Company1&lt;/P&gt;&lt;P&gt;123&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Company4&lt;/P&gt;&lt;P&gt;345&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;NULL&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Company1&lt;/P&gt;&lt;P&gt;456&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Company3&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2026 18:42:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Convert-Field-Contents-into-Separate-Fields-Flags-Y-N/m-p/2551066#M110438</guid>
      <dc:creator>SDT</dc:creator>
      <dc:date>2026-06-10T18:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Convert Field Contents into Separate Fields (Flags Y/N)</title>
      <link>https://community.qlik.com/t5/App-Development/Convert-Field-Contents-into-Separate-Fields-Flags-Y-N/m-p/2551084#M110439</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/72080"&gt;@SDT&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this what you are expecting?&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="alejandroquinones_1-1781121917498.png" style="width: 550px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/188841iB27B3FDAE3166461/image-dimensions/550x147?v=v2" width="550" height="147" role="button" title="alejandroquinones_1-1781121917498.png" alt="alejandroquinones_1-1781121917498.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;If so, you need to use the GENERIC LOAD prefix to turn every distinct value in the AGENCY field into a new column. Find attached the .qvf file. Here is the code, and basically how it works:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Steps 1 &amp;amp; 2:&lt;/STRONG&gt; It loads your raw data and creates a master list (FinalTable) containing every unique PART number.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Step 3:&lt;/STRONG&gt;&amp;nbsp;It filters out the blanks and "NULL" agencies, assigning a 1 to everything that is left (your flag).&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Step 4.&lt;/STRONG&gt;&amp;nbsp;The Generic load is a special Qlik function that takes your vertical list and shatters it into a bunch of temporary mini-tables, one dedicated to each unique AGENCY.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Step 5:&lt;/STRONG&gt;&amp;nbsp;The for loop joins the table created in steps 1 &amp;amp; 2 for each agency.&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;LI-CODE lang="markup"&gt;// 1. Load the raw data using INLINE
RawData:
LOAD * INLINE [
PART, AGENCY
123, Company1
123, Company4
345, NULL
456, Company1
456, Company3
];

// 2. Create the base table with ALL distinct PART numbers
FinalTable:
LOAD DISTINCT 
    PART 
RESIDENT RawData;

// 3. Prepare data for the Generic Load
Generic_Prep:
LOAD 
    PART,
    AGENCY,
    1 as FlagValue
RESIDENT RawData
WHERE Len(Trim(AGENCY)) &amp;gt; 0 AND AGENCY &amp;lt;&amp;gt; 'NULL';

// 4. Perform the Generic Load
AgencyFlags_Tmp:
GENERIC LOAD 
    PART, 
    AGENCY, 
    FlagValue 
RESIDENT Generic_Prep;

DROP TABLE Generic_Prep;

//5. Left join the table with all PART values for every agency
FOR i = NoOfTables()-1 to 0 STEP -1 

  LET vTable=TableName($(i)); 
  
  //Just join tables with the following pattern
  IF WildMatch('$(vTable)', 'AgencyFlags_Tmp.*') THEN 
  
    LEFT JOIN (FinalTable) 
    	
   	LOAD * RESIDENT [$(vTable)]; 
    
    DROP TABLE  [$(vTable)]; 
    
  ENDIF 
  
NEXT i


DROP TABLE RawData;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you also need to turn the null values into 0, I tried using the NullAsValue statement, but it's not working for me—apparently because of the LEFT JOIN. Maybe someone can help us out here; I haven't used this statement much.&lt;/P&gt;&lt;P&gt;However, I managed to do it another way with another FOR loop. In the .qvf file, you'll see two tabs: &lt;STRONG&gt;'Generic Load (v1)'&lt;/STRONG&gt; is the version with the flags as 1 and null values, and the &lt;STRONG&gt;'Generic Load (v2)'&lt;/STRONG&gt; tab contains an extra step to clean these values to 0.&lt;/P&gt;&lt;P&gt;Help on Generic load:&amp;nbsp;&lt;A href="https://qlikviewcookbook.com/2010/05/use-cases-for-generic-load/" target="_blank"&gt;https://qlikviewcookbook.com/2010/05/use-cases-for-generic-load/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2026 20:38:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Convert-Field-Contents-into-Separate-Fields-Flags-Y-N/m-p/2551084#M110439</guid>
      <dc:creator>alejandroquinones</dc:creator>
      <dc:date>2026-06-10T20:38:30Z</dc:date>
    </item>
  </channel>
</rss>

