<?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: creating a new dimension in the load script in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657803#M49239</link>
    <description>&lt;P&gt;For this case there are several possibilities to do it&lt;/P&gt;&lt;P&gt;1-you can simply add the condition in your LOAD instruction&lt;/P&gt;&lt;LI-CODE lang="python"&gt;LOAD if(len(Vendor)&amp;gt;0,'Has Vendor','No Vendor') as VendorFlag,* INLINE [
    Site, Vendor
    Site 1, Vendor 1
    Site 2, Vendor 2
    Site 3, Vendor 1
    Site 3, Vendor 2
    Site 3, Vendor 4
    Site 5
    Site 7, Vendor 1
    Site 7, Vendor 4
    Site 10, Vendor 2
    Site 10, Vendor 3
    Site 11
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 465px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/25546iB3F645D875BD5E4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;otherwise if you absolutely want to use the count(), you can for example use this script :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;INPUTS:

LOAD * INLINE [
    Site, Vendor
    Site 1, Vendor 1
    Site 2, Vendor 2
    Site 3, Vendor 1
    Site 3, Vendor 2
    Site 3, Vendor 4
    Site 5
    Site 7, Vendor 1
    Site 7, Vendor 4
    Site 10, Vendor 2
    Site 10, Vendor 3
    Site 11
];



RESULTS:

LOAD

Site,

if(count(if(len(Vendor)&amp;gt;0, Vendor))&amp;gt;0 ,'Has Vendor','No Vendor') as VendorFlag

Resident INPUTS

Group By Site;

DROP Table INPUTS;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;results :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 476px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/25547i98F3189D71CB432C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;</description>
    <pubDate>Sun, 15 Dec 2019 13:05:35 GMT</pubDate>
    <dc:creator>Taoufiq_Zarra</dc:creator>
    <dc:date>2019-12-15T13:05:35Z</dc:date>
    <item>
      <title>creating a new dimension in the load script</title>
      <link>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657756#M49232</link>
      <description>&lt;P&gt;In the load script, we'd like to create a new dimension based on the result of an expression.&amp;nbsp; This works in the expression editor, but I'm not sure we can do it in the load script.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We want a dimension flag, based on there being a value for 'A'.&lt;/P&gt;&lt;P&gt;The logic would be for a site:&lt;/P&gt;&lt;P&gt;if(count(A)&amp;gt;0,'Has A','Does not have A') as "Flag, Has A"&lt;/P&gt;&lt;P&gt;So if dimension A is null for a site, the value of "Flag, Has A" would be 'Does not have Flag A'.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this possible in the load script?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 19:27:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657756#M49232</guid>
      <dc:creator>firmographs</dc:creator>
      <dc:date>2024-11-16T19:27:30Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new dimension in the load script</title>
      <link>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657764#M49233</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;yes it is possible by using Group By and load from Resident.&lt;/P&gt;&lt;P&gt;give more details of your script to help you efficiently (with a sample data is more efficient)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 18:40:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657764#M49233</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2019-12-14T18:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new dimension in the load script</title>
      <link>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657768#M49234</link>
      <description>&lt;P&gt;&lt;SPAN&gt;This is my draft script, which I know is not right yet, but it shows the logic we are after:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if(count(Vendor)&amp;gt;0,'Has Vendor,'No Vendor') as "Vendor Flag"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sample data is attached.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Dec 2019 20:30:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657768#M49234</guid>
      <dc:creator>firmographs</dc:creator>
      <dc:date>2019-12-14T20:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new dimension in the load script</title>
      <link>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657803#M49239</link>
      <description>&lt;P&gt;For this case there are several possibilities to do it&lt;/P&gt;&lt;P&gt;1-you can simply add the condition in your LOAD instruction&lt;/P&gt;&lt;LI-CODE lang="python"&gt;LOAD if(len(Vendor)&amp;gt;0,'Has Vendor','No Vendor') as VendorFlag,* INLINE [
    Site, Vendor
    Site 1, Vendor 1
    Site 2, Vendor 2
    Site 3, Vendor 1
    Site 3, Vendor 2
    Site 3, Vendor 4
    Site 5
    Site 7, Vendor 1
    Site 7, Vendor 4
    Site 10, Vendor 2
    Site 10, Vendor 3
    Site 11
];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;output :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 465px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/25546iB3F645D875BD5E4A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;otherwise if you absolutely want to use the count(), you can for example use this script :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;INPUTS:

LOAD * INLINE [
    Site, Vendor
    Site 1, Vendor 1
    Site 2, Vendor 2
    Site 3, Vendor 1
    Site 3, Vendor 2
    Site 3, Vendor 4
    Site 5
    Site 7, Vendor 1
    Site 7, Vendor 4
    Site 10, Vendor 2
    Site 10, Vendor 3
    Site 11
];



RESULTS:

LOAD

Site,

if(count(if(len(Vendor)&amp;gt;0, Vendor))&amp;gt;0 ,'Has Vendor','No Vendor') as VendorFlag

Resident INPUTS

Group By Site;

DROP Table INPUTS;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;results :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 476px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/25547i98F3189D71CB432C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;cheers,&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2019 13:05:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657803#M49239</guid>
      <dc:creator>Taoufiq_Zarra</dc:creator>
      <dc:date>2019-12-15T13:05:35Z</dc:date>
    </item>
    <item>
      <title>Re: creating a new dimension in the load script</title>
      <link>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657819#M49241</link>
      <description>&lt;P&gt;Thank you for your help!&amp;nbsp; The 2nd solution is the one we adopted.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Dec 2019 18:20:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/creating-a-new-dimension-in-the-load-script/m-p/1657819#M49241</guid>
      <dc:creator>firmographs</dc:creator>
      <dc:date>2019-12-15T18:20:38Z</dc:date>
    </item>
  </channel>
</rss>

