<?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 Qlikview scripting sum if statements in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1552015#M598440</link>
    <description>&lt;P&gt;Good afternoon all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been struggling though this for a week and I resigned that I can't get it.&amp;nbsp; In Microsoft access the working formula is&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum(IIf([Unit Code 3]="3102",-[201150],IIf(([201110]+[507200])=0,[121100]+[122100],IIf(([121100]+[122100]+[507200])&amp;lt;&amp;gt;0,-[201110],0)))) AS Amount&amp;nbsp;&lt;/P&gt;&lt;P&gt;in QV fieldname for Unit Code 3 is&amp;nbsp;acct_unit3&amp;nbsp; .&amp;nbsp; The field for the account #'s &lt;STRONG&gt;acct&lt;/STRONG&gt; is&amp;nbsp;Match(&lt;STRONG&gt;acct&lt;/STRONG&gt;,120100,121100,122100,122105,201110,201150,507200);&amp;nbsp;&lt;/P&gt;&lt;P&gt;and field for $ amount is dom_amount&lt;/P&gt;&lt;P&gt;A Coworker told me to do code like below&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;Test_01:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AffiliateCode|po_num|po_line, //key field&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sum(dom_amount) as Test_amt&lt;BR /&gt;Resident&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Temp_02&lt;BR /&gt;Where&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Match(acct,201100,507200)&lt;BR /&gt;Group By&lt;BR /&gt;AffiliateCode|po_num|po_line;&lt;/P&gt;&lt;P&gt;Left Join(Temp_02)&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;AffiliateCode|po_num|po_line,&lt;BR /&gt;if(Test_amt = 0,1,0) as Condition_01&lt;BR /&gt;Resident&lt;BR /&gt;Test_01;&lt;/P&gt;&lt;P&gt;DROP Table Test_01;&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;and then to continue this for the rest of the conditions? He is swamped and I need more help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Mar 2019 21:24:51 GMT</pubDate>
    <dc:creator>jmcdermott</dc:creator>
    <dc:date>2019-03-04T21:24:51Z</dc:date>
    <item>
      <title>Qlikview scripting sum if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1552015#M598440</link>
      <description>&lt;P&gt;Good afternoon all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been struggling though this for a week and I resigned that I can't get it.&amp;nbsp; In Microsoft access the working formula is&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sum(IIf([Unit Code 3]="3102",-[201150],IIf(([201110]+[507200])=0,[121100]+[122100],IIf(([121100]+[122100]+[507200])&amp;lt;&amp;gt;0,-[201110],0)))) AS Amount&amp;nbsp;&lt;/P&gt;&lt;P&gt;in QV fieldname for Unit Code 3 is&amp;nbsp;acct_unit3&amp;nbsp; .&amp;nbsp; The field for the account #'s &lt;STRONG&gt;acct&lt;/STRONG&gt; is&amp;nbsp;Match(&lt;STRONG&gt;acct&lt;/STRONG&gt;,120100,121100,122100,122105,201110,201150,507200);&amp;nbsp;&lt;/P&gt;&lt;P&gt;and field for $ amount is dom_amount&lt;/P&gt;&lt;P&gt;A Coworker told me to do code like below&lt;/P&gt;&lt;P&gt;--------------------------------------------------------------&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;/P&gt;&lt;P&gt;Test_01:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AffiliateCode|po_num|po_line, //key field&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;sum(dom_amount) as Test_amt&lt;BR /&gt;Resident&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Temp_02&lt;BR /&gt;Where&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Match(acct,201100,507200)&lt;BR /&gt;Group By&lt;BR /&gt;AffiliateCode|po_num|po_line;&lt;/P&gt;&lt;P&gt;Left Join(Temp_02)&lt;/P&gt;&lt;P&gt;LOAD&lt;BR /&gt;AffiliateCode|po_num|po_line,&lt;BR /&gt;if(Test_amt = 0,1,0) as Condition_01&lt;BR /&gt;Resident&lt;BR /&gt;Test_01;&lt;/P&gt;&lt;P&gt;DROP Table Test_01;&lt;/P&gt;&lt;P&gt;------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;and then to continue this for the rest of the conditions? He is swamped and I need more help.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 21:24:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1552015#M598440</guid>
      <dc:creator>jmcdermott</dc:creator>
      <dc:date>2019-03-04T21:24:51Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview scripting sum if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1552061#M598441</link>
      <description>&lt;P&gt;It looks like he is using the left joins to take vertically stacked fields and turning them to horizontal fields.&lt;/P&gt;&lt;P&gt;I don't want to send you down another rabbit hole, but would the script below achieve the same thing using preload statements (not tested, ymmv):&lt;/P&gt;&lt;P&gt;Temp:&lt;BR /&gt;load KeyField,&lt;BR /&gt;if (acct_unit3 = '3102',201150_Amt * -1,&lt;BR /&gt;if (201110_507200_Amt = 0,121100_122100_Amt,&lt;BR /&gt;if (121100_122100_507200_Amt != 0,201110_Amt * -1,0))) as Amount;&lt;/P&gt;&lt;P&gt;load KeyField,&lt;BR /&gt;acct_unit3,&lt;BR /&gt;sum(201150_Amt) as 201150_Amt,&lt;BR /&gt;sum(201110_507200_Amt) as 201110_507200_Amt,&lt;BR /&gt;sum(121100_122100_Amt) as 121100_122100_Amt,&lt;BR /&gt;sum(121100_122100_507200_Amt) as 121100_122100_507200_Amt,&lt;BR /&gt;sum(201110_Amt) as 201110_Amt&lt;BR /&gt;group by KeyField;&lt;/P&gt;&lt;P&gt;load&lt;BR /&gt;AffiliateCode|po_num|po_line as KeyField, //key field&lt;BR /&gt;acct_unit3&lt;BR /&gt;if (acct = 201150,dom_amount,0.0) as 201150_Amt,&lt;BR /&gt;if (Match(acct,201110,507200) &amp;gt; 0,dom_amount,0.0) as 201110_507200_Amt,&lt;BR /&gt;if (Match(acct,121100,122100) &amp;gt; 0,dom_amount,0.0) as 121100_122100_Amt,&lt;BR /&gt;if (Match(acct,121100,122100,507200) &amp;gt; 0,dom_amount,0.0) as 121100_122100_507200_Amt,&lt;BR /&gt;if (acct = 201110,dom_amount,0.0) as 201110_Amt&lt;BR /&gt;resident YOUR_TABLE where Match(acct,120100,121100,122100,122105,201110,201150,507200) &amp;gt; 0&lt;/P&gt;</description>
      <pubDate>Mon, 04 Mar 2019 22:40:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1552061#M598441</guid>
      <dc:creator>jwjackso</dc:creator>
      <dc:date>2019-03-04T22:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview scripting sum if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1581182#M598442</link>
      <description>&lt;P&gt;Good morning,&lt;/P&gt;&lt;P&gt;I put in the code that was suggested like below but I am getting an error.&amp;nbsp; What am I doing incorrectly?&lt;/P&gt;&lt;P&gt;Error:________________________________________________________________________&amp;nbsp;&lt;/P&gt;&lt;P&gt;Invalid expression&lt;BR /&gt;load&lt;BR /&gt;AffiliateCode|po_num|po_line as KeyField,&lt;BR /&gt;acct_unit3,&lt;BR /&gt;if (acct = 201150,dom_amount,0.0) as aAmt,&lt;BR /&gt;if (Match(acct,201110,507200) &amp;gt; 0,dom_amount,0.0) as bAmt,&lt;BR /&gt;if (Match(acct,121100,122100) &amp;gt; 0,dom_amount,0.0) as cAmt,&lt;BR /&gt;if (Match(acct,121100,122100,507200) &amp;gt; 0,dom_amount,0.0) as dAmt,&lt;BR /&gt;if (acct = 201110,dom_amount,0.0) as eAmt&lt;BR /&gt;resident&lt;BR /&gt;Temp_02&lt;BR /&gt;where&lt;BR /&gt;Match(acct,120100,121100,122100,122105,201110,201150,507200) &amp;gt; 0&lt;/P&gt;&lt;P&gt;________________________________________________________________________________&lt;/P&gt;&lt;P&gt;Code I used below:&lt;/P&gt;&lt;P&gt;_______________________________________________________________________________&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp_03:&lt;BR /&gt;load KeyField,&lt;BR /&gt;if (acct_unit3 = '3102',aAmt * -1,&lt;BR /&gt;if (bAmt = 0,cAmt,&lt;BR /&gt;if (dAmt = 0,eAmt * -1,0))) as Amount;&lt;/P&gt;&lt;P&gt;load KeyField,&lt;BR /&gt;acct_unit3,&lt;BR /&gt;sum(aAmt) as aAmt,&lt;BR /&gt;sum(bAmt) as bAmt,&lt;BR /&gt;sum(cAmt) as cAmt,&lt;BR /&gt;sum(dAmt) as dAmt,&lt;BR /&gt;sum(eAmt) as eAmt&lt;BR /&gt;group by KeyField;&lt;/P&gt;&lt;P&gt;load&lt;BR /&gt;AffiliateCode|po_num|po_line as KeyField, //key field&lt;BR /&gt;acct_unit3,&lt;BR /&gt;if (acct = 201150,dom_amount,0.0) as aAmt,&lt;BR /&gt;if (Match(acct,201110,507200) &amp;gt; 0,dom_amount,0.0) as bAmt,&lt;BR /&gt;if (Match(acct,121100,122100) &amp;gt; 0,dom_amount,0.0) as cAmt,&lt;BR /&gt;if (Match(acct,121100,122100,507200) &amp;gt; 0,dom_amount,0.0) as dAmt,&lt;BR /&gt;if (acct = 201110,dom_amount,0.0) as eAmt&lt;BR /&gt;resident&lt;BR /&gt;Temp_02&amp;nbsp;//YOUR_TABLE&lt;BR /&gt;where&lt;BR /&gt;Match(acct,120100,121100,122100,122105,201110,201150,507200) &amp;gt; 0;&lt;BR /&gt;___________________________________________________________________________&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 15:19:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1581182#M598442</guid>
      <dc:creator>jmcdermott</dc:creator>
      <dc:date>2019-05-16T15:19:48Z</dc:date>
    </item>
    <item>
      <title>Re: Qlikview scripting sum if statements</title>
      <link>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1592143#M598443</link>
      <description>&lt;P&gt;Code that works&lt;/P&gt;&lt;P&gt;NoConcatenate&lt;BR /&gt;Temp_03:&lt;BR /&gt;load AffiliateCode|po_num|po_line,&lt;BR /&gt;if (aAmt &amp;lt;&amp;gt; 0,aAmt * -1,&lt;BR /&gt;if (bAmt = 0,cAmt,&lt;BR /&gt;if (dAmt = 0,eAmt * -1,0))) as Amount;&lt;/P&gt;&lt;P&gt;load AffiliateCode|po_num|po_line,&lt;BR /&gt;acct_unit3,&lt;BR /&gt;sum(aAmt) as aAmt,&lt;BR /&gt;sum(bAmt) as bAmt,&lt;BR /&gt;sum(cAmt) as cAmt,&lt;BR /&gt;sum(dAmt) as dAmt,&lt;BR /&gt;sum(eAmt) as eAmt&lt;BR /&gt;Group By&lt;BR /&gt;AffiliateCode|po_num|po_line,&lt;BR /&gt;acct_unit3;&lt;/P&gt;&lt;P&gt;load&lt;BR /&gt;AffiliateCode|po_num|po_line, //key field&lt;BR /&gt;acct_unit3,&lt;BR /&gt;if (acct = 201150,dom_amount,0.0) as aAmt,&lt;BR /&gt;if (Match(acct,201110,507200) &amp;gt; 0,dom_amount,0.0) as bAmt,&lt;BR /&gt;if (Match(acct,121100,122100) &amp;gt; 0,dom_amount,0.0) as cAmt,&lt;BR /&gt;if (Match(acct,121100,122100,507200) &amp;gt; 0,dom_amount,0.0) as dAmt,&lt;BR /&gt;if (acct = 201110,dom_amount,0.0) as eAmt&lt;BR /&gt;resident&lt;BR /&gt;Temp_02&lt;BR /&gt;where&lt;BR /&gt;Match(acct,120100,121100,122100,122105,201110,201150,507200) &amp;gt; 0;&lt;BR /&gt;//YOUR_TABLE&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 15:48:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Qlikview-scripting-sum-if-statements/m-p/1592143#M598443</guid>
      <dc:creator>jmcdermott</dc:creator>
      <dc:date>2019-06-14T15:48:03Z</dc:date>
    </item>
  </channel>
</rss>

