<?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: sql case condition in qlikview in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951864#M980121</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the response.&lt;/P&gt;&lt;P&gt;i m not using any group by in my script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i m using the above expression in my pivot table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;even if i remove the sum of the amt, i m not getting any values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the field TRD and C_TRD is already a summed up field in sql procedure. but in qlikview, it is not summed up in the script, thatsy i m using sum in the expression&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Aug 2015 08:37:50 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-08-19T08:37:50Z</dc:date>
    <item>
      <title>sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951862#M980119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i have the following sql case statement&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: blue;"&gt;CASE&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;when&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/127897"&gt;@Name&lt;/a&gt;&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;=&lt;/SPAN&gt; &lt;SPAN style="color: red;"&gt;'SOT1'&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;THEN&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;CASE&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;WHEN &lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;AMT&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;/&lt;/SPAN&gt;&lt;SPAN style="color: fuchsia;"&gt;nullif&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;TRD&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;,&lt;/SPAN&gt;0&lt;SPAN style="color: gray;"&gt;)*&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;C_TRD&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt; &lt;SPAN style="color: gray;"&gt;&amp;gt;=&lt;/SPAN&gt; &lt;SPAN style="color: teal;"&gt;TGT1&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;THEN&lt;/SPAN&gt; 75 &lt;SPAN style="color: gray;"&gt;+&lt;/SPAN&gt; &lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: fuchsia;"&gt;cast&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(((&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;AMT&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;/&lt;/SPAN&gt;&lt;SPAN style="color: fuchsia;"&gt;nullif&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;TRD&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;,&lt;/SPAN&gt;0&lt;SPAN style="color: gray;"&gt;)*&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;C_TRD&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)-&lt;/SPAN&gt;&lt;SPAN style="color: teal;"&gt;TGT1&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)/&lt;/SPAN&gt;250 &lt;SPAN style="color: blue;"&gt;AS&lt;/SPAN&gt; &lt;SPAN style="color: blue;"&gt;INT&lt;/SPAN&gt;&lt;SPAN style="color: gray;"&gt;)*&lt;/SPAN&gt;25&lt;SPAN style="color: gray;"&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;ELSE&lt;/SPAN&gt; 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;END&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: blue;"&gt;ELSE&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ffffff; font-size: 9.5pt; font-family: Consolas;"&gt; &lt;SPAN style="color: #3366ff; background: yellow;"&gt;CASE&lt;/SPAN&gt;&lt;SPAN style="color: #3366ff; background: yellow;"&gt; WHEN (AMT/nullif(TRD,0)*C_TRD) &amp;gt;= TGT1 THEN cast((TGT1)*.01&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;+((&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;AMT&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;/&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;nullif&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;TRD&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; background: yellow;"&gt;0)*C_TRD)-TGT1)*0.1 as int)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: #3366ff; background: yellow;"&gt; ELSE 0&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 9.5pt; font-family: Consolas; color: #3366ff; background: yellow;"&gt; END&lt;/SPAN&gt;&lt;SPAN style="color: #3366ff; font-size: 9.5pt; font-family: Consolas;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;C_TRD is the specific days count in TRD and i did this specific count in qlikview by a variable vCTD)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How can i do this in qlikview.&lt;/P&gt;&lt;P&gt;I m currently trying the expression for the fist case statement as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=if(NAME='SOT1', IF(SUM(AMT)/(sum(&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;TRD&lt;/SPAN&gt;)*sum({&amp;lt;DEC_MonthYear=, DEC_Date= {'vCTD'}&amp;gt;}&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;TRD&lt;/SPAN&gt;))&amp;gt;=&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;TGT1 &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;,75 + if(((SUM(AMT)/(sum(&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;TRD&lt;/SPAN&gt;)*sum({&amp;lt;DEC_MonthYear=, DEC_Date= {'vCTD'}&amp;gt;}&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;TRD&lt;/SPAN&gt;)))-&lt;SPAN style="color: #3366ff; font-family: Consolas; font-size: 12.6666669845581px; background-color: #ffff00;"&gt;TGT1 &lt;/SPAN&gt;)/250,25),0))&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;But i m not getting any values. please help me on this&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Nov 2020 18:02:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951862#M980119</guid>
      <dc:creator />
      <dc:date>2020-11-20T18:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951863#M980120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;why are you doing sum of the columns? in your case statement there is no sum?&lt;/P&gt;&lt;P&gt;also&lt;/P&gt;&lt;P&gt;check group by clause if you properly using it in your load statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;post your application so that we can help you better&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sasi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 08:12:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951863#M980120</guid>
      <dc:creator>sasiparupudi1</dc:creator>
      <dc:date>2015-08-19T08:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951864#M980121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks for the response.&lt;/P&gt;&lt;P&gt;i m not using any group by in my script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i m using the above expression in my pivot table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;even if i remove the sum of the amt, i m not getting any values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the field TRD and C_TRD is already a summed up field in sql procedure. but in qlikview, it is not summed up in the script, thatsy i m using sum in the expression&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 08:37:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951864#M980121</guid>
      <dc:creator />
      <dc:date>2015-08-19T08:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951865#M980122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Translating SQL code piece-by-piece into somethng that QlikView can handle is never a good idea. Better deduce the reasoning behind this code, and implement the same using QlikView techniques. That way you'll get a solution that is efficient, performs well and can be maintained.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW if you don't change the DBMS, almost all SQL code can be copied as-is in a LOAD script. But I have a hunch that you lifted this part from a stored procedure, correct?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 09:16:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951865#M980122</guid>
      <dc:creator>Peter_Cammaert</dc:creator>
      <dc:date>2015-08-19T09:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951866#M980123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't understand what your expression really does, but I can see several problems:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;You have &lt;SPAN style="color: #ff0000;"&gt;naked field references&lt;/SPAN&gt; inside it (=field references that are not wrapped in an aggregation function) and this is a recipe for problems. See &lt;A href="https://community.qlik.com/qlik-blogpost/3779"&gt;Use Aggregation Functions!&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;You refer to &lt;SPAN style="color: #99cc00;"&gt;variables enclosed in single quotes&lt;/SPAN&gt;. This will not work. Either you need to use dollar expansion within single quotes, or you use the naked variable without single quotes.&lt;/LI&gt;&lt;LI&gt;The &lt;SPAN style="color: #0000ff;"&gt;third If()-function&lt;/SPAN&gt; has no comparison in the condition. Is this really correct?&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=if(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #ff0000;"&gt;NAME&lt;/SPAN&gt;='SOT1', &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SUM(AMT)/(sum(TRD)*sum({&amp;lt;DEC_MonthYear=, DEC_Date= {&lt;SPAN style="color: #339966;"&gt;&lt;SPAN style="color: #99cc00;"&gt;'vCTD&lt;/SPAN&gt;'&lt;/SPAN&gt;}&amp;gt;}TRD))&amp;nbsp; &amp;gt;=&amp;nbsp; &lt;SPAN style="color: #ff0000;"&gt;TGT1&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 75 + &lt;SPAN style="color: #0000ff;"&gt;if(((&lt;/SPAN&gt;SUM(AMT)/(sum(TRD)*sum({&amp;lt;DEC_MonthYear=, DEC_Date= {&lt;SPAN style="color: #99cc00;"&gt;'vCTD'&lt;/SPAN&gt;}&amp;gt;}TRD)))-&lt;SPAN style="color: #ff0000;"&gt;TGT1&lt;/SPAN&gt; )/250,25),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 09:23:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951866#M980123</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2015-08-19T09:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951867#M980124</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Peter,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yes, the sql statement is from a procedure&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 10:00:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951867#M980124</guid>
      <dc:creator />
      <dc:date>2015-08-19T10:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951868#M980125</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Henric,&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But, can you please help me with the correct expression&lt;/P&gt;&lt;P&gt;plsss&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 10:01:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951868#M980125</guid>
      <dc:creator />
      <dc:date>2015-08-19T10:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: sql case condition in qlikview</title>
      <link>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951869#M980126</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As &lt;A href="https://community.qlik.com/qlik-users/3540"&gt;pcammaert&lt;/A&gt; says: "Translating SQL code piece-by-piece into somethng that QlikView can handle is never a good idea." I think it is better that you try to understand the requirement and write this formula in a simpler way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HIC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Aug 2015 10:23:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/sql-case-condition-in-qlikview/m-p/951869#M980126</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2015-08-19T10:23:00Z</dc:date>
    </item>
  </channel>
</rss>

