<?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 Variable via SQL in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Variable-via-SQL/m-p/1694814#M53137</link>
    <description>&lt;P&gt;Hello.&lt;BR /&gt;&lt;BR /&gt;I have got an app which has a SQL Select query to select fields and populate a table for a report.&lt;/P&gt;&lt;P&gt;For the front page of the NPrinting report, I need to create a variable for the max date for a specific field. However, I do not know how to create a variable using SQL script.&lt;/P&gt;&lt;P&gt;Load*;&lt;/P&gt;&lt;P&gt;SQL select dp.Number&lt;BR /&gt;,dp.InceptionDate&lt;BR /&gt;,dp.EffectiveDate&lt;BR /&gt;,dp.ExpiryDate&lt;BR /&gt;,dp.CancellationDate&lt;BR /&gt;,datediff(year,dp.InceptionDate,dp.EffectiveDate) as TermNumber&lt;BR /&gt;,dlob.LobCd&lt;BR /&gt;,dlob.LobDesc&lt;BR /&gt;,SUM(fp.GWP) AS GrossWrittenPremium&lt;BR /&gt;,SUM(fp.NWP) AS NetWrittenPremium&lt;BR /&gt;,SUM(fp.Commission) AS Commission&lt;/P&gt;&lt;P&gt;from [GBQPS1SDA01DMA].[cdm].[FactPrm] fp&lt;BR /&gt;join [GBQPS1SDA01DMA].[cdm].[DLOB] dlob on fp.FKLineOfBusinessOID = dlob.LineOfBusinessOID&lt;BR /&gt;join [GBQPS1SDA01DMA].[cdm].[Dim] dp on fp.FKOID = dp.OID&lt;BR /&gt;and dp.CurrentRecordIndicator = '1'&lt;BR /&gt;join [GBQPS1SDA01DMA].[cdm].[DIMPrT] dpt on fp.FKTrOID = dpt.PrmTOID&lt;BR /&gt;and dpt.CurrentRecordIndicator = '1'&lt;/P&gt;&lt;P&gt;where 1=1&lt;BR /&gt;and dlob.LobCd IN ('B0100', 'B0098', 'B0099')&lt;BR /&gt;AND dp.EffectiveDate = dp.ExpiryDate&lt;/P&gt;&lt;P&gt;GROUP BY dp.Number&lt;BR /&gt;,dp.InceptionDate&lt;BR /&gt;,dp.EffectiveDate&lt;BR /&gt;,dp.ExpiryDate&lt;BR /&gt;,dp.CancellationDate&lt;BR /&gt;,datediff(year,dp.InceptionDate,dp.EffectiveDate)&lt;BR /&gt;,dlob.LobCd&lt;BR /&gt;,dlob.LobDesc&lt;BR /&gt;HAVING SUM(fp.GWP) &amp;lt;&amp;gt; 0;&lt;/P&gt;&lt;P&gt;exit script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create a variable to pass through to NPrinting which gives me the Max value of EffectiveDate, so essentially;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let vDateTO = Date(Max([dp.EffectiveDate],'DD-MM-YYYY')); - however this seems to not work,&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 18:45:56 GMT</pubDate>
    <dc:creator>QlikBeginner1</dc:creator>
    <dc:date>2024-11-16T18:45:56Z</dc:date>
    <item>
      <title>Variable via SQL</title>
      <link>https://community.qlik.com/t5/App-Development/Variable-via-SQL/m-p/1694814#M53137</link>
      <description>&lt;P&gt;Hello.&lt;BR /&gt;&lt;BR /&gt;I have got an app which has a SQL Select query to select fields and populate a table for a report.&lt;/P&gt;&lt;P&gt;For the front page of the NPrinting report, I need to create a variable for the max date for a specific field. However, I do not know how to create a variable using SQL script.&lt;/P&gt;&lt;P&gt;Load*;&lt;/P&gt;&lt;P&gt;SQL select dp.Number&lt;BR /&gt;,dp.InceptionDate&lt;BR /&gt;,dp.EffectiveDate&lt;BR /&gt;,dp.ExpiryDate&lt;BR /&gt;,dp.CancellationDate&lt;BR /&gt;,datediff(year,dp.InceptionDate,dp.EffectiveDate) as TermNumber&lt;BR /&gt;,dlob.LobCd&lt;BR /&gt;,dlob.LobDesc&lt;BR /&gt;,SUM(fp.GWP) AS GrossWrittenPremium&lt;BR /&gt;,SUM(fp.NWP) AS NetWrittenPremium&lt;BR /&gt;,SUM(fp.Commission) AS Commission&lt;/P&gt;&lt;P&gt;from [GBQPS1SDA01DMA].[cdm].[FactPrm] fp&lt;BR /&gt;join [GBQPS1SDA01DMA].[cdm].[DLOB] dlob on fp.FKLineOfBusinessOID = dlob.LineOfBusinessOID&lt;BR /&gt;join [GBQPS1SDA01DMA].[cdm].[Dim] dp on fp.FKOID = dp.OID&lt;BR /&gt;and dp.CurrentRecordIndicator = '1'&lt;BR /&gt;join [GBQPS1SDA01DMA].[cdm].[DIMPrT] dpt on fp.FKTrOID = dpt.PrmTOID&lt;BR /&gt;and dpt.CurrentRecordIndicator = '1'&lt;/P&gt;&lt;P&gt;where 1=1&lt;BR /&gt;and dlob.LobCd IN ('B0100', 'B0098', 'B0099')&lt;BR /&gt;AND dp.EffectiveDate = dp.ExpiryDate&lt;/P&gt;&lt;P&gt;GROUP BY dp.Number&lt;BR /&gt;,dp.InceptionDate&lt;BR /&gt;,dp.EffectiveDate&lt;BR /&gt;,dp.ExpiryDate&lt;BR /&gt;,dp.CancellationDate&lt;BR /&gt;,datediff(year,dp.InceptionDate,dp.EffectiveDate)&lt;BR /&gt;,dlob.LobCd&lt;BR /&gt;,dlob.LobDesc&lt;BR /&gt;HAVING SUM(fp.GWP) &amp;lt;&amp;gt; 0;&lt;/P&gt;&lt;P&gt;exit script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create a variable to pass through to NPrinting which gives me the Max value of EffectiveDate, so essentially;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let vDateTO = Date(Max([dp.EffectiveDate],'DD-MM-YYYY')); - however this seems to not work,&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:45:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Variable-via-SQL/m-p/1694814#M53137</guid>
      <dc:creator>QlikBeginner1</dc:creator>
      <dc:date>2024-11-16T18:45:56Z</dc:date>
    </item>
  </channel>
</rss>

