<?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: If()Sum Expression Syntax Problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104378#M600859</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David. I think you can replace this long If() statement with a shorter fabs()&amp;nbsp; which returns the absolute value&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3332996368408px;"&gt;Sum(fabs(ToTime - FromTime))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 03 Nov 2018 19:55:41 GMT</pubDate>
    <dc:creator>andrey_krylov</dc:creator>
    <dc:date>2018-11-03T19:55:41Z</dc:date>
    <item>
      <title>If()Sum Expression Syntax Problem</title>
      <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104377#M600858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have [ShiftTime] fields coming in for example as the following text fields:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;18:00 - 03:00&lt;/P&gt;&lt;P&gt;08:30 - 12:00&lt;/P&gt;&lt;P&gt;13:30 - 16:00&lt;/P&gt;&lt;P&gt;22:00 - 01:30&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;where the text field represents a "From" to a "To Time".&amp;nbsp; I break these fields apart to obtain separated "From" and "To" values in the script using the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Subfield((ShiftTime),' - ',1) as FromTime,&lt;/P&gt;&lt;P&gt;Subfield((ShiftTime),' - ',-1) as ToTime,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With a 24Hour clock, I have the following Expression to calculate the &lt;STRONG&gt;"&lt;/STRONG&gt;ShiftLength&lt;STRONG&gt;"&lt;/STRONG&gt; by subtracting the "FromTime" from the "ToTime".&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if(Sum(ToTime - FromTime)&amp;lt;0,(Sum(ToTime - FromTime)* -1),Sum(ToTime - FromTime))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Where the calculated "ShiftLength" is a negative value, as would be the case in &lt;SPAN style="font-size: 13.3333px;"&gt;22:00 - 01:30, the negative value is multiplied by [-1].&amp;nbsp; This works on a line by line basis .&amp;nbsp; But now, I also want to get the total value of all "ShiftLength" values and cannot get the correct syntax as in:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sum(if(Sum(ToTime - FromTime)&amp;lt;0,(Sum(ToTime - FromTime)* -1),Sum(ToTime - FromTime))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;The preceding line gives me a syntax error.&amp;nbsp; And, I am never sure if it should be a Sum(If) or an If(Sum)....................&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Any help would be much appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Dave&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 18:01:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104377#M600858</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-03T18:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: If()Sum Expression Syntax Problem</title>
      <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104378#M600859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi David. I think you can replace this long If() statement with a shorter fabs()&amp;nbsp; which returns the absolute value&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3332996368408px;"&gt;Sum(fabs(ToTime - FromTime))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 19:55:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104378#M600859</guid>
      <dc:creator>andrey_krylov</dc:creator>
      <dc:date>2018-11-03T19:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: If()Sum Expression Syntax Problem</title>
      <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104379#M600860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrey:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Works perfectly.&amp;nbsp; Thanks very much.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 20:14:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104379#M600860</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-03T20:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: If()Sum Expression Syntax Problem</title>
      <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104380#M600861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Did you intend to have '22:00 - 01:30' get a shift length of 20:30?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 20:29:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104380#M600861</guid>
      <dc:creator>mikevwang</dc:creator>
      <dc:date>2018-11-03T20:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: If()Sum Expression Syntax Problem</title>
      <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104381#M600862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;You are welcome. And the &lt;SPAN lang="en"&gt;error is caused by &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13.3332996368408px;"&gt;&lt;STRONG&gt;sum&lt;/STRONG&gt;(if(&lt;STRONG&gt;Sum&lt;/STRONG&gt;.&lt;STRONG&gt; &lt;/STRONG&gt;To solve it the first summation should&amp;nbsp; be aggregated&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13.3332996368408px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;sum(Aggr(if(Sum(ToTime - FromTime)&amp;lt;0,(Sum(ToTime - FromTime)* -1),Sum(ToTime - FromTime), Dim1, Dim2...))&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 20:33:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104381#M600862</guid>
      <dc:creator>andrey_krylov</dc:creator>
      <dc:date>2018-11-03T20:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: If()Sum Expression Syntax Problem</title>
      <link>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104382#M600863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Andrey&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And thanks again. This problem has been bugging since 10:00AM this morning.&amp;nbsp; The 'absolute value' solution is best as you have mentioned - it is so simple!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dave&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 03 Nov 2018 20:53:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/If-Sum-Expression-Syntax-Problem/m-p/104382#M600863</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-03T20:53:20Z</dc:date>
    </item>
  </channel>
</rss>

