<?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: Translating a CASE statement from SQL into QV in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438644#M1163213</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get numerous syntax errors when moving a SQL statement over to QV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Dec 2012 13:19:37 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-12-17T13:19:37Z</dc:date>
    <item>
      <title>Translating a CASE statement from SQL into QV</title>
      <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438641#M1163208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello. So I'm trying to convert a SQL script that I know works outside of QlikView, but I'm not understanding how to bring in the CASE statement that sits in the FROM part of the script. I keep getting syntax errors on reload. Some have suggested mapping but I really don't think I want it for this instance.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within the FROM portion of the SQL script a variable called 'Plan_Status' is created like below..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;FROM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes INNER JOIN ( &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; SELECT PROJ_NO, cpr_program,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;'Plan_STATUS' =&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;CASE&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NULL) AND (TRIM_PlanOnAir_Target_Date &amp;gt;= CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)) THEN 'Grey'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I also don't think I need the inner join to pull what I want, but I do need that 'Plan_Status' variable field to be Red, Yellow, or Grey depending on the logic above.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 14:13:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438641#M1163208</guid>
      <dc:creator />
      <dc:date>2012-12-14T14:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Translating a CASE statement from SQL into QV</title>
      <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438642#M1163209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you post the complete select statement?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 19:58:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438642#M1163209</guid>
      <dc:creator>fosuzuki</dc:creator>
      <dc:date>2012-12-14T19:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: Translating a CASE statement from SQL into QV</title>
      <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438643#M1163211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's ugly but ok.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Region,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Market,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Program,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.PROJ_NO,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Plan_On_Air_Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.PLAN149,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.PLAN150,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.ACTUAL099,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.ACTUAL100,&lt;/P&gt;&lt;P&gt;&amp;nbsp; count(CPR.CASPR.Active_Project_Attributes.PROJ_NO),&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Actual_Transport_Delivery_Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_PlanOnAir_Target_Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TransHealth_Status_DT.FCST_STATUS,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_30days_before_PlanOnAir_Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp; TransHealth_Status_DT.Fcst_Project_Due_Status,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_FcstOnAir_Target_Date,&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Fcst_On_Air_Date&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes INNER JOIN ( &lt;/P&gt;&lt;P&gt;&amp;nbsp; SELECT PROJ_NO, cpr_program,&lt;/P&gt;&lt;P&gt;'Plan_STATUS' =&lt;/P&gt;&lt;P&gt;CASE&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NULL) AND (TRIM_PlanOnAir_Target_Date &amp;gt;= CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)) THEN 'Grey'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) and (TRIM_Actual_Transport_Delivery_Date &amp;lt;= TRIM_PlanOnAir_Target_Date)THEN 'Green'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) and ((TRIM_Actual_Transport_Delivery_Date &amp;gt;= TRIM_PlanOnAir_Target_Date) AND (TRIM_Actual_Transport_Delivery_Date &amp;lt;= TRIM_30days_before_PlanOnAir_Date)) THEN 'Yellow'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date is NULL) and (TRIM_PlanOnAir_Target_Date &amp;lt; CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)) THEN 'Red'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) and (TRIM_Actual_Transport_Delivery_Date &amp;gt; TRIM_30days_before_PlanOnAir_Date) THEN 'Red'&lt;/P&gt;&lt;P&gt;ELSE 'Other'&lt;/P&gt;&lt;P&gt;END,&lt;/P&gt;&lt;P&gt;'Tranport_Status' =&lt;/P&gt;&lt;P&gt;CASE&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) THEN 'Transport Delivered'&lt;/P&gt;&lt;P&gt;WHEN ((CASPR.Active_Project_Attributes.TRIM_Actual_Submit_Order_Date IS NULL) And (TRIM_Actual_Transport_Delivery_Date IS NULL)) THEN 'Transport not Ord'&lt;/P&gt;&lt;P&gt;WHEN ((CASPR.Active_Project_Attributes.TRIM_Actual_Submit_Order_Date IS NOT NULL) And (TRIM_Actual_Transport_Delivery_Date IS NULL)) THEN 'Transport Ord'&lt;/P&gt;&lt;P&gt;ELSE 'Other'&lt;/P&gt;&lt;P&gt;END,&lt;/P&gt;&lt;P&gt;'Plan_Project_Due_Status' =&lt;/P&gt;&lt;P&gt;CASE &lt;/P&gt;&lt;P&gt;WHEN ((TRIM_Actual_Transport_Delivery_Date IS NULL) AND ( CASPR.Active_Project_Attributes.TRIM_PlanOnAir_Target_Date - CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)&amp;gt;60)) THEN 'Due after 60 days'&lt;/P&gt;&lt;P&gt;WHEN (((TRIM_Actual_Transport_Delivery_Date IS NULL)) And ( CASPR.Active_Project_Attributes.TRIM_PlanOnAir_Target_Date - CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)&amp;lt;0)) THEN 'Past Due'&lt;/P&gt;&lt;P&gt;WHEN ((TRIM_Actual_Transport_Delivery_Date IS NULL) AND ( CASPR.Active_Project_Attributes.TRIM_PlanOnAir_Target_Date - CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)&amp;lt;=60)) THEN 'Due next 60 days'&lt;/P&gt;&lt;P&gt;ELSE 'Other'&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;,'FCST_STATUS' =&lt;/P&gt;&lt;P&gt;CASE&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NULL) AND (TRIM_FcstOnAir_Target_Date &amp;gt;= CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)) THEN 'Grey'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) and (TRIM_Actual_Transport_Delivery_Date &amp;lt;= TRIM_FcstOnAir_Target_Date)THEN 'Green'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) and ((TRIM_Actual_Transport_Delivery_Date &amp;gt;= TRIM_FcstOnAir_Target_Date) AND (TRIM_Actual_Transport_Delivery_Date &amp;lt;= (TRIM_Fcst_On_Air_Date-30))) THEN 'Yellow'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date is NULL) and (TRIM_FcstOnAir_Target_Date &amp;lt; CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)) THEN 'Red'&lt;/P&gt;&lt;P&gt;WHEN (TRIM_Actual_Transport_Delivery_Date IS NOT NULL) and (TRIM_Actual_Transport_Delivery_Date &amp;gt; (TRIM_Fcst_On_Air_Date-30)) THEN 'Red'&lt;/P&gt;&lt;P&gt;ELSE 'Other'&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;,'Fcst_Project_Due_Status' =&lt;/P&gt;&lt;P&gt;CASE &lt;/P&gt;&lt;P&gt;WHEN ((TRIM_Actual_Transport_Delivery_Date IS NULL) AND ( CASPR.Active_Project_Attributes.TRIM_FcstOnAir_Target_Date - CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)&amp;gt;60)) THEN 'Due after 60 days'&lt;/P&gt;&lt;P&gt;WHEN (((TRIM_Actual_Transport_Delivery_Date IS NULL)) And ( CASPR.Active_Project_Attributes.TRIM_FcstOnAir_Target_Date - CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)&amp;lt;0)) THEN 'Past Due'&lt;/P&gt;&lt;P&gt;WHEN ((TRIM_Actual_Transport_Delivery_Date IS NULL) AND ( CASPR.Active_Project_Attributes.TRIM_FcstOnAir_Target_Date - CAST(FLOOR(CAST(GETDATE() AS FLOAT)) AS DATETIME)&amp;lt;=60)) THEN 'Due next 60 days'&lt;/P&gt;&lt;P&gt;ELSE 'Other'&lt;/P&gt;&lt;P&gt;END&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FROM CPR.CASPR.Active_Project_Attributes&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&amp;nbsp; TransHealth_Status_DT ON (CPR.CASPR.Active_Project_Attributes.PROJ_NO=TransHealth_Status_DT.PROJ_NO)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;WHERE&lt;/P&gt;&lt;P&gt;&amp;nbsp; (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Program&amp;nbsp; IN&amp;nbsp; ( '1st Carrier','2nd Carrier','3rd Carrier','4th Carrier','5th Carrier','6th Carrier','LTE','NSB'&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; AND&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Fcst_On_Air_Date&amp;nbsp; BETWEEN&amp;nbsp; '01/01/2012 00:0:0'&amp;nbsp; AND&amp;nbsp; '08/16/2012 00:0:0'&lt;/P&gt;&lt;P&gt;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;GROUP BY&lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Region, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Market, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.CPR_Program, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.PROJ_NO, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Plan_On_Air_Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.PLAN149, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.PLAN150, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.ACTUAL099, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.ACTUAL100, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Actual_Transport_Delivery_Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_PlanOnAir_Target_Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp; TransHealth_Status_DT.FCST_STATUS, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_30days_before_PlanOnAir_Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp; TransHealth_Status_DT.Fcst_Project_Due_Status, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_FcstOnAir_Target_Date, &lt;/P&gt;&lt;P&gt;&amp;nbsp; CPR.CASPR.Active_Project_Attributes.TRIM_Fcst_On_Air_Date&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Dec 2012 20:01:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438643#M1163211</guid>
      <dc:creator />
      <dc:date>2012-12-14T20:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Translating a CASE statement from SQL into QV</title>
      <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438644#M1163213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I get numerous syntax errors when moving a SQL statement over to QV.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 13:19:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438644#M1163213</guid>
      <dc:creator />
      <dc:date>2012-12-17T13:19:37Z</dc:date>
    </item>
    <item>
      <title>Re: Translating a CASE statement from SQL into QV</title>
      <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438645#M1163215</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;Are you using ODBC or OLE DB? Which type of errors are you getting? Everything after the SQL or SELECT statement goes directly into the driver, then sent to the database. So there may be a syntax issue (i. e.: not accepted keyword) in either the driver or the RDBMS, as long as QlikView does not do anything in that part.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Miguel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 13:23:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438645#M1163215</guid>
      <dc:creator>Miguel_Angel_Baeyens</dc:creator>
      <dc:date>2012-12-17T13:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Translating a CASE statement from SQL into QV</title>
      <link>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438646#M1163216</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try changing the CASE syntax to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SELECT CASE WHEN [Condition] THEN [ThenStatement] ELSE [ElseStatement] END AS "[FieldName]"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Dec 2012 13:47:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Translating-a-CASE-statement-from-SQL-into-QV/m-p/438646#M1163216</guid>
      <dc:creator>fosuzuki</dc:creator>
      <dc:date>2012-12-17T13:47:26Z</dc:date>
    </item>
  </channel>
</rss>

