<?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: Urgent! Make a field value 0 based on repeating ID. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116350#M91093</link>
    <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;DataSource:
Load * Inline [
ProjectID,FundingCompany,Amount
101,xyz,20000
102,CompanyABC,80000
102,CompanyQWE,80000
103,CompanyABC,4000
];



CompanyAmount:
Load Distinct
    ProjectID,
    count(distinct FundingCompany) as CompanyAmount
Resident DataSource
group By
	ProjectID
;


NoConcatenate

DataSource_Temp2:
Load
    *
Resident DataSource;

left join(DataSource_Temp2)

Load
    ProjectID,
    0 as multiplier
Resident CompanyAmount
where CompanyAmount = 2
;

NoConcatenate

DataSource_Temp3:
Load
    ProjectID,
    FundingCompany,
    Amount,
    if(FundingCompany='CompanyABC' and not isnull(multiplier),multiplier,1)	as multiplier
Resident DataSource_Temp2;


NoConcatenate

DataSource_Final:
Load
    ProjectID,
    FundingCompany,
    Amount*multiplier as Amount
Resident DataSource_Temp3;


Drop Tables DataSource,DataSource_Temp2,DataSource_Temp3,CompanyAmount;&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 13 Sep 2023 07:35:09 GMT</pubDate>
    <dc:creator>zhaofeng</dc:creator>
    <dc:date>2023-09-13T07:35:09Z</dc:date>
    <item>
      <title>Urgent! Make a field value 0 based on repeating ID.</title>
      <link>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116317#M91089</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I have a dataset in which a project_id and funding_company and amount columns exist. if same project id has two different funding_company, and if one of the company is "CompanyABC" then the amount column of "CompanyABC" must be made 0.&amp;nbsp; If only one funding_comapany exists for a project_id, then the amount should remain same. Backend script would be appreciated.How to achieve this in Qlik sense?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AnupamRaj_0-1694584983728.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/116177i976ADC7BDB338692/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AnupamRaj_0-1694584983728.png" alt="AnupamRaj_0-1694584983728.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 06:02:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116317#M91089</guid>
      <dc:creator>Mapuna</dc:creator>
      <dc:date>2023-09-13T06:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent! Make a field value 0 based on repeating ID.</title>
      <link>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116350#M91093</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;DataSource:
Load * Inline [
ProjectID,FundingCompany,Amount
101,xyz,20000
102,CompanyABC,80000
102,CompanyQWE,80000
103,CompanyABC,4000
];



CompanyAmount:
Load Distinct
    ProjectID,
    count(distinct FundingCompany) as CompanyAmount
Resident DataSource
group By
	ProjectID
;


NoConcatenate

DataSource_Temp2:
Load
    *
Resident DataSource;

left join(DataSource_Temp2)

Load
    ProjectID,
    0 as multiplier
Resident CompanyAmount
where CompanyAmount = 2
;

NoConcatenate

DataSource_Temp3:
Load
    ProjectID,
    FundingCompany,
    Amount,
    if(FundingCompany='CompanyABC' and not isnull(multiplier),multiplier,1)	as multiplier
Resident DataSource_Temp2;


NoConcatenate

DataSource_Final:
Load
    ProjectID,
    FundingCompany,
    Amount*multiplier as Amount
Resident DataSource_Temp3;


Drop Tables DataSource,DataSource_Temp2,DataSource_Temp3,CompanyAmount;&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 13 Sep 2023 07:35:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116350#M91093</guid>
      <dc:creator>zhaofeng</dc:creator>
      <dc:date>2023-09-13T07:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Urgent! Make a field value 0 based on repeating ID.</title>
      <link>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116412#M91100</link>
      <description>&lt;P&gt;Thanks for the help. But i found a shorter solution and it worked. Hope this thread helps someone &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Solution:&lt;/P&gt;
&lt;P&gt;Left join(MAIN_TABLE)&lt;BR /&gt;Count:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Project_ID,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; count( distinct Funding_Company) as count&lt;BR /&gt;Resident MAIN_TABLE&lt;BR /&gt;Group By Project_ID;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Final_Table:&lt;BR /&gt;Load&amp;nbsp;&lt;BR /&gt;   *,&lt;BR /&gt;   if(count&amp;gt;1 and Funding_Company='CompanyABC',0,amount) as updated_amount;&lt;/P&gt;
&lt;P&gt;Resident MAIN_TABLE;&lt;BR /&gt;Drop Table MAIN_TABLE;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 09:41:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Urgent-Make-a-field-value-0-based-on-repeating-ID/m-p/2116412#M91100</guid>
      <dc:creator>Mapuna</dc:creator>
      <dc:date>2023-09-13T09:41:49Z</dc:date>
    </item>
  </channel>
</rss>

