<?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 Trying to replicate a SQL CTE load from data stored in QVD. in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Trying-to-replicate-a-SQL-CTE-load-from-data-stored-in-QVD/m-p/1640441#M594827</link>
    <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to replicate the results of a SQL cte in the QlikView load script. All the necessary data is stored in QVDs and are loaded into the QVW each morning. Therefore the SQL process seems unnecessary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SQL process basically calculates the ending A/R balance at the end of each accounting period (acctPeriod) by A/R (arid) and Provider ID (doc_no).&amp;nbsp; I'm able to load the current amount for each period in Qlik properly. The balance I can pull the ending as of the last period properly, but all previous are being loaded as the current ending.&amp;nbsp; I'm not sure if I should do this in the script or just attempt to use set analysis in the front end. Any ideas would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*----SQL Ending AR Query----*/&lt;BR /&gt;with cte as (&lt;BR /&gt;select distinct e.doc_no, f.arid, f.acctPeriod&lt;BR /&gt;from dbo.wcsvc e, dbo.acctDates f) select cte.*,&lt;/P&gt;&lt;P&gt;(&lt;BR /&gt;select ISNULL(sum(svc_amt),0) from dbo.wcsvc g&lt;BR /&gt;where g.doc_no = cte.doc_no and g.arid_no = cte.arid and g.svc_period = cte.acctPeriod&amp;nbsp;&lt;BR /&gt;)&lt;BR /&gt;as CurAmount,&lt;/P&gt;&lt;P&gt;(&lt;BR /&gt;select ISNULL(sum(svc_amt),0) from dbo.wcsvc g&lt;BR /&gt;where g.doc_no = cte.doc_no and g.arid_no = cte.arid and g.svc_period &amp;lt;= cte.acctPeriod&amp;nbsp;&lt;BR /&gt;)&lt;BR /&gt;as CurBalance,&lt;/P&gt;&lt;P&gt;acctDates.accountingDate,&lt;BR /&gt;'ENDAR' as datacode&lt;/P&gt;&lt;P&gt;from cte&lt;BR /&gt;left join dbo.acctDates on cte.acctPeriod = acctDates.acctPeriod and cte.arid = acctDates.arid&lt;BR /&gt;order by doc_no, arid, acctPeriod ASC&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*-----Qlik script-----*/&lt;/P&gt;&lt;P&gt;CurAmount:&lt;BR /&gt;LOAD&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_acctDates,&lt;BR /&gt;%Key_doc,&lt;BR /&gt;Sum(svc_amt) AS CurAmount,&lt;BR /&gt;Sum(IF(svc_period&amp;lt;= svc_period,svc_amt)) as CurBal&lt;/P&gt;&lt;P&gt;Resident [wcsvc]&lt;/P&gt;&lt;P&gt;Group by&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_acctDates,&lt;BR /&gt;%Key_doc;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;CurBalance:&lt;BR /&gt;LOAD&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_doc,&lt;BR /&gt;Sum(svc_amt) AS Balance&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident [wcsvc]&lt;/P&gt;&lt;P&gt;Group by&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_doc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Oct 2019 15:34:09 GMT</pubDate>
    <dc:creator>Jacob_Poole</dc:creator>
    <dc:date>2019-10-28T15:34:09Z</dc:date>
    <item>
      <title>Trying to replicate a SQL CTE load from data stored in QVD.</title>
      <link>https://community.qlik.com/t5/QlikView/Trying-to-replicate-a-SQL-CTE-load-from-data-stored-in-QVD/m-p/1640441#M594827</link>
      <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to replicate the results of a SQL cte in the QlikView load script. All the necessary data is stored in QVDs and are loaded into the QVW each morning. Therefore the SQL process seems unnecessary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SQL process basically calculates the ending A/R balance at the end of each accounting period (acctPeriod) by A/R (arid) and Provider ID (doc_no).&amp;nbsp; I'm able to load the current amount for each period in Qlik properly. The balance I can pull the ending as of the last period properly, but all previous are being loaded as the current ending.&amp;nbsp; I'm not sure if I should do this in the script or just attempt to use set analysis in the front end. Any ideas would be greatly appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*----SQL Ending AR Query----*/&lt;BR /&gt;with cte as (&lt;BR /&gt;select distinct e.doc_no, f.arid, f.acctPeriod&lt;BR /&gt;from dbo.wcsvc e, dbo.acctDates f) select cte.*,&lt;/P&gt;&lt;P&gt;(&lt;BR /&gt;select ISNULL(sum(svc_amt),0) from dbo.wcsvc g&lt;BR /&gt;where g.doc_no = cte.doc_no and g.arid_no = cte.arid and g.svc_period = cte.acctPeriod&amp;nbsp;&lt;BR /&gt;)&lt;BR /&gt;as CurAmount,&lt;/P&gt;&lt;P&gt;(&lt;BR /&gt;select ISNULL(sum(svc_amt),0) from dbo.wcsvc g&lt;BR /&gt;where g.doc_no = cte.doc_no and g.arid_no = cte.arid and g.svc_period &amp;lt;= cte.acctPeriod&amp;nbsp;&lt;BR /&gt;)&lt;BR /&gt;as CurBalance,&lt;/P&gt;&lt;P&gt;acctDates.accountingDate,&lt;BR /&gt;'ENDAR' as datacode&lt;/P&gt;&lt;P&gt;from cte&lt;BR /&gt;left join dbo.acctDates on cte.acctPeriod = acctDates.acctPeriod and cte.arid = acctDates.arid&lt;BR /&gt;order by doc_no, arid, acctPeriod ASC&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*-----Qlik script-----*/&lt;/P&gt;&lt;P&gt;CurAmount:&lt;BR /&gt;LOAD&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_acctDates,&lt;BR /&gt;%Key_doc,&lt;BR /&gt;Sum(svc_amt) AS CurAmount,&lt;BR /&gt;Sum(IF(svc_period&amp;lt;= svc_period,svc_amt)) as CurBal&lt;/P&gt;&lt;P&gt;Resident [wcsvc]&lt;/P&gt;&lt;P&gt;Group by&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_acctDates,&lt;BR /&gt;%Key_doc;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;CurBalance:&lt;BR /&gt;LOAD&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_doc,&lt;BR /&gt;Sum(svc_amt) AS Balance&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Resident [wcsvc]&lt;/P&gt;&lt;P&gt;Group by&lt;BR /&gt;%Key_arid,&lt;BR /&gt;%Key_doc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Oct 2019 15:34:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Trying-to-replicate-a-SQL-CTE-load-from-data-stored-in-QVD/m-p/1640441#M594827</guid>
      <dc:creator>Jacob_Poole</dc:creator>
      <dc:date>2019-10-28T15:34:09Z</dc:date>
    </item>
  </channel>
</rss>

