<?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: Dynamic Views from Excel in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2456525#M98512</link>
    <description>&lt;P&gt;i tried to first have a script section in my tempalte app that i convert my excel files into qvds and then in another section the dynamic views code&amp;nbsp; below . Then i create a dynamic view in a selection app i click the refresh button of the dynamic view and its working. But the problem arises when i try to add a new value in my excel file that the dynamic view can't show. From what i guess is that the selection app will get the values from the template's app qvds and wont first run the conversion from the excel file .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendQVDWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND mixmatch([$(ColName)],$(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE mixmatch([$(ColName)],$(Values))';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendSQLWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND $(ColName) IN ( $(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE $(ColName) IN ( $(Values) )';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB BuildValueList(VarName, TableName, ColName, QuoteChrNum)&lt;BR /&gt;IF ($(QuoteChrNum) = 0) THEN&lt;BR /&gt;LET LOADEXPR = 'Concat($(ColName),' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ELSE&lt;BR /&gt;LET CHREXPR = ' chr(' &amp;amp; '$(QuoteChrNum)' &amp;amp; ') ';&lt;BR /&gt;LET LOADEXPR = 'Concat( $(CHREXPR) &amp;amp; $(ColName) &amp;amp; $(CHREXPR)' &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ENDIF&lt;BR /&gt;_TempTable:&lt;BR /&gt;LOAD $(LOADEXPR) Resident $(TableName);&lt;BR /&gt;Let vNoOfRows = NoOfRows('_TempTable');&lt;BR /&gt;IF $(vNoOfRows)&amp;gt; 0 THEN&lt;BR /&gt;LET $(VarName) = Peek('CombinedData',0,'_TempTable');&lt;BR /&gt;ENDIF&lt;BR /&gt;drop table _TempTable;&lt;BR /&gt;drop table '$(TableName)';&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// CHANGE 1: Update these blocks of INLINE table loads to correspond to the names of the fields from your&lt;BR /&gt;// Shopping Cart app. The contents inside the $() in the record body of the INLINE load statements&lt;BR /&gt;// must match the names of the fields from your shopping cart app that the user makes selections on.&lt;BR /&gt;// If the database column name (lor QVD field name) for any of the selection fields has a different&lt;BR /&gt;// name, you need to alter the right hand side of the SET xxxx_COLNAME statement to reflect that&lt;BR /&gt;// field's corrresponding database column (or QVD field) name;&lt;BR /&gt;// &lt;BR /&gt;// All fields for On Demand are prefixed with od and the following to indicate selected or associated&lt;BR /&gt;// values&lt;BR /&gt;// ods = Selected values&lt;BR /&gt;// odo = Associated values&lt;BR /&gt;// odso = Selected/assocaited values&lt;BR /&gt;//&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SET OfficeID ='';&lt;BR /&gt;OdagBinding:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;VAL&lt;BR /&gt;$(odo_OfficeID){"quote": "", "delimiter": ""}&lt;BR /&gt;];&lt;BR /&gt;SET OfficeID_COLNAME='OfficeID';&lt;BR /&gt;CALL BuildValueList('OfficeID', 'OdagBinding', 'VAL', 39); // 39 is for single quote wrapping values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE #2: Alter this with a leading 'WHERE &amp;lt;condition&amp;gt;' if you want your SQL statement (below)&lt;BR /&gt;// to have a non-changing WHERE clause in addition to the clauses that will be inserted&lt;BR /&gt;// by the shopping cart app (it is fine to leave it as is).&lt;/P&gt;
&lt;P&gt;SET WHERE_PART = '';&lt;/P&gt;
&lt;P&gt;// CHANGE 3: Update the list of field names here to reflect each of the field names variables you have on the&lt;BR /&gt;// left hand side (assignment target) of the first SET statement of the SET statement pairs in change&lt;BR /&gt;// 1 above. Note that in this case we're using ExtendQVDWhere which uses Qlik's mixmatch to build a &lt;BR /&gt;// where clause to test whether the inbound records match the conditions. If your the LOAD statement&lt;BR /&gt;// in which WHERE_PART is applied is querying a SQL database, use the 'ExtendSQLWhere' subroutine&lt;BR /&gt;// instead (and, of course, don't forget to include your database CONNECT statement).&lt;/P&gt;
&lt;P&gt;FOR EACH fldname IN 'OfficeID'&lt;BR /&gt;LET vallist = $(fldname);&lt;BR /&gt;WHEN (IsNull(vallist)) LET vallist = '';&lt;BR /&gt;IF len(vallist) &amp;gt; 0 THEN&lt;BR /&gt;CALL ExtendQVDWhere('$(fldname)','vallist');&lt;BR /&gt;ENDIF&lt;BR /&gt;NEXT fldname&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;TRACE Generated WHERE clause: ;&lt;BR /&gt;TRACE $(WHERE_PART);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE # 4: Modify the list of columns (or QVD fields) you wish to load from your database table (or QVD)&lt;BR /&gt;// but leave the the $(WHERE_PART) portion of SQL (or LOAD) statement alone at the end.&lt;BR /&gt;// &lt;BR /&gt;// Note that you can have more than one of these dynamiclly alterered SELECT (or LOAD) statements&lt;BR /&gt;// by replicating the sections from CHANGE #2 thru this change #5 and customize which WHERE clauses&lt;BR /&gt;// will be inserted by altering the list of fields in the FOR EACH statement in Change #3.&lt;/P&gt;
&lt;P&gt;LET FOLDER='lib://DataFiles';&lt;BR /&gt;LET Employees_QVD='[$(FOLDER)/Employees.qvd](qvd)';&lt;/P&gt;
&lt;P&gt;Employees:&lt;BR /&gt;LOAD&lt;BR /&gt;EmpID,&lt;BR /&gt;"First Name",&lt;BR /&gt;"Last Name",&lt;BR /&gt;DateOfBirth,&lt;BR /&gt;StartDate,&lt;BR /&gt;EndDate,&lt;BR /&gt;OfficeID,&lt;BR /&gt;JobTitle&lt;BR /&gt;FROM $(Employees_QVD)&lt;BR /&gt;$(WHERE_PART);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Office:&lt;BR /&gt;load&lt;BR /&gt;OfficeID,&lt;BR /&gt;OfficeAddress,&lt;BR /&gt;OfficeCity,&lt;BR /&gt;OfficeCountry,&lt;BR /&gt;OfficeFax,&lt;BR /&gt;OfficePhone,&lt;BR /&gt;OfficePostalCode,&lt;BR /&gt;OfficeStateProvince&lt;BR /&gt;FROM [lib://DataFiles/Office.qvd](qvd)&lt;BR /&gt;where exists(OfficeID)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 May 2024 09:26:31 GMT</pubDate>
    <dc:creator>Christos500</dc:creator>
    <dc:date>2024-05-27T09:26:31Z</dc:date>
    <item>
      <title>Dynamic Views from Excel</title>
      <link>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2453009#M98149</link>
      <description>&lt;P&gt;greetings,&lt;/P&gt;
&lt;P&gt;does anyone know if it is possible to create a template app for a dynamic view solution that refreshes the data from an excel file instead of a database or a qvd ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 06:25:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2453009#M98149</guid>
      <dc:creator>Christos500</dc:creator>
      <dc:date>2024-05-16T06:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Views from Excel</title>
      <link>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2453210#M98156</link>
      <description>&lt;P&gt;Shure, thats no problem. It is just al reload and you can use every source.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2024 12:50:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2453210#M98156</guid>
      <dc:creator>JHuis</dc:creator>
      <dc:date>2024-05-16T12:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Views from Excel</title>
      <link>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2453505#M98184</link>
      <description>&lt;P&gt;so what's the process? First load from an excel file, then convert it to qvd and then read the qvd ?&lt;/P&gt;
&lt;P&gt;because in the template app script we have only commands like ' CALL ExtendQVDWhere('$(fldname)','vallist') ' for qvd case or&amp;nbsp;&amp;nbsp;' CALL ExtendSQLWhere('$(fldname)','vallist') '&amp;nbsp; for sql database.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 07:36:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2453505#M98184</guid>
      <dc:creator>Christos500</dc:creator>
      <dc:date>2024-05-17T07:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Views from Excel</title>
      <link>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2456525#M98512</link>
      <description>&lt;P&gt;i tried to first have a script section in my tempalte app that i convert my excel files into qvds and then in another section the dynamic views code&amp;nbsp; below . Then i create a dynamic view in a selection app i click the refresh button of the dynamic view and its working. But the problem arises when i try to add a new value in my excel file that the dynamic view can't show. From what i guess is that the selection app will get the values from the template's app qvds and wont first run the conversion from the excel file .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendQVDWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND mixmatch([$(ColName)],$(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE mixmatch([$(ColName)],$(Values))';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendSQLWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND $(ColName) IN ( $(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE $(ColName) IN ( $(Values) )';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB BuildValueList(VarName, TableName, ColName, QuoteChrNum)&lt;BR /&gt;IF ($(QuoteChrNum) = 0) THEN&lt;BR /&gt;LET LOADEXPR = 'Concat($(ColName),' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ELSE&lt;BR /&gt;LET CHREXPR = ' chr(' &amp;amp; '$(QuoteChrNum)' &amp;amp; ') ';&lt;BR /&gt;LET LOADEXPR = 'Concat( $(CHREXPR) &amp;amp; $(ColName) &amp;amp; $(CHREXPR)' &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ENDIF&lt;BR /&gt;_TempTable:&lt;BR /&gt;LOAD $(LOADEXPR) Resident $(TableName);&lt;BR /&gt;Let vNoOfRows = NoOfRows('_TempTable');&lt;BR /&gt;IF $(vNoOfRows)&amp;gt; 0 THEN&lt;BR /&gt;LET $(VarName) = Peek('CombinedData',0,'_TempTable');&lt;BR /&gt;ENDIF&lt;BR /&gt;drop table _TempTable;&lt;BR /&gt;drop table '$(TableName)';&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// CHANGE 1: Update these blocks of INLINE table loads to correspond to the names of the fields from your&lt;BR /&gt;// Shopping Cart app. The contents inside the $() in the record body of the INLINE load statements&lt;BR /&gt;// must match the names of the fields from your shopping cart app that the user makes selections on.&lt;BR /&gt;// If the database column name (lor QVD field name) for any of the selection fields has a different&lt;BR /&gt;// name, you need to alter the right hand side of the SET xxxx_COLNAME statement to reflect that&lt;BR /&gt;// field's corrresponding database column (or QVD field) name;&lt;BR /&gt;// &lt;BR /&gt;// All fields for On Demand are prefixed with od and the following to indicate selected or associated&lt;BR /&gt;// values&lt;BR /&gt;// ods = Selected values&lt;BR /&gt;// odo = Associated values&lt;BR /&gt;// odso = Selected/assocaited values&lt;BR /&gt;//&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SET OfficeID ='';&lt;BR /&gt;OdagBinding:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;VAL&lt;BR /&gt;$(odo_OfficeID){"quote": "", "delimiter": ""}&lt;BR /&gt;];&lt;BR /&gt;SET OfficeID_COLNAME='OfficeID';&lt;BR /&gt;CALL BuildValueList('OfficeID', 'OdagBinding', 'VAL', 39); // 39 is for single quote wrapping values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE #2: Alter this with a leading 'WHERE &amp;lt;condition&amp;gt;' if you want your SQL statement (below)&lt;BR /&gt;// to have a non-changing WHERE clause in addition to the clauses that will be inserted&lt;BR /&gt;// by the shopping cart app (it is fine to leave it as is).&lt;/P&gt;
&lt;P&gt;SET WHERE_PART = '';&lt;/P&gt;
&lt;P&gt;// CHANGE 3: Update the list of field names here to reflect each of the field names variables you have on the&lt;BR /&gt;// left hand side (assignment target) of the first SET statement of the SET statement pairs in change&lt;BR /&gt;// 1 above. Note that in this case we're using ExtendQVDWhere which uses Qlik's mixmatch to build a &lt;BR /&gt;// where clause to test whether the inbound records match the conditions. If your the LOAD statement&lt;BR /&gt;// in which WHERE_PART is applied is querying a SQL database, use the 'ExtendSQLWhere' subroutine&lt;BR /&gt;// instead (and, of course, don't forget to include your database CONNECT statement).&lt;/P&gt;
&lt;P&gt;FOR EACH fldname IN 'OfficeID'&lt;BR /&gt;LET vallist = $(fldname);&lt;BR /&gt;WHEN (IsNull(vallist)) LET vallist = '';&lt;BR /&gt;IF len(vallist) &amp;gt; 0 THEN&lt;BR /&gt;CALL ExtendQVDWhere('$(fldname)','vallist');&lt;BR /&gt;ENDIF&lt;BR /&gt;NEXT fldname&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;TRACE Generated WHERE clause: ;&lt;BR /&gt;TRACE $(WHERE_PART);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE # 4: Modify the list of columns (or QVD fields) you wish to load from your database table (or QVD)&lt;BR /&gt;// but leave the the $(WHERE_PART) portion of SQL (or LOAD) statement alone at the end.&lt;BR /&gt;// &lt;BR /&gt;// Note that you can have more than one of these dynamiclly alterered SELECT (or LOAD) statements&lt;BR /&gt;// by replicating the sections from CHANGE #2 thru this change #5 and customize which WHERE clauses&lt;BR /&gt;// will be inserted by altering the list of fields in the FOR EACH statement in Change #3.&lt;/P&gt;
&lt;P&gt;LET FOLDER='lib://DataFiles';&lt;BR /&gt;LET Employees_QVD='[$(FOLDER)/Employees.qvd](qvd)';&lt;/P&gt;
&lt;P&gt;Employees:&lt;BR /&gt;LOAD&lt;BR /&gt;EmpID,&lt;BR /&gt;"First Name",&lt;BR /&gt;"Last Name",&lt;BR /&gt;DateOfBirth,&lt;BR /&gt;StartDate,&lt;BR /&gt;EndDate,&lt;BR /&gt;OfficeID,&lt;BR /&gt;JobTitle&lt;BR /&gt;FROM $(Employees_QVD)&lt;BR /&gt;$(WHERE_PART);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Office:&lt;BR /&gt;load&lt;BR /&gt;OfficeID,&lt;BR /&gt;OfficeAddress,&lt;BR /&gt;OfficeCity,&lt;BR /&gt;OfficeCountry,&lt;BR /&gt;OfficeFax,&lt;BR /&gt;OfficePhone,&lt;BR /&gt;OfficePostalCode,&lt;BR /&gt;OfficeStateProvince&lt;BR /&gt;FROM [lib://DataFiles/Office.qvd](qvd)&lt;BR /&gt;where exists(OfficeID)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 May 2024 09:26:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2456525#M98512</guid>
      <dc:creator>Christos500</dc:creator>
      <dc:date>2024-05-27T09:26:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Views from Excel</title>
      <link>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2456826#M98534</link>
      <description>&lt;P&gt;I just found the solution by myself. First you need to have a script section in the template app that loads the data from excel file/s and then convert it/them into&amp;nbsp;qvd/s . Then you have to put the dynamic views code below but we have two cases :&lt;/P&gt;
&lt;P&gt;1) Case with a star schema&amp;nbsp; (dimension and fact tables ) and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) Case with one table ( for many reasons we ve decided to join all of our tables with qvds, excel etc into one single table ).&lt;/P&gt;
&lt;P&gt;For the 1) case we need to put the $(WHERE_PART) clause into the fact table but for the 2) case we must not !!!&lt;/P&gt;
&lt;P&gt;Below the code for the dynamic views :&lt;/P&gt;
&lt;P&gt;1) case:&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendQVDWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND mixmatch([$(ColName)],$(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE mixmatch([$(ColName)],$(Values))';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendSQLWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND $(ColName) IN ( $(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE $(ColName) IN ( $(Values) )';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB BuildValueList(VarName, TableName, ColName, QuoteChrNum)&lt;BR /&gt;IF ($(QuoteChrNum) = 0) THEN&lt;BR /&gt;LET LOADEXPR = 'Concat($(ColName),' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ELSE&lt;BR /&gt;LET CHREXPR = ' chr(' &amp;amp; '$(QuoteChrNum)' &amp;amp; ') ';&lt;BR /&gt;LET LOADEXPR = 'Concat( $(CHREXPR) &amp;amp; $(ColName) &amp;amp; $(CHREXPR)' &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ENDIF&lt;BR /&gt;_TempTable:&lt;BR /&gt;LOAD $(LOADEXPR) Resident $(TableName);&lt;BR /&gt;Let vNoOfRows = NoOfRows('_TempTable');&lt;BR /&gt;IF $(vNoOfRows)&amp;gt; 0 THEN&lt;BR /&gt;LET $(VarName) = Peek('CombinedData',0,'_TempTable');&lt;BR /&gt;ENDIF&lt;BR /&gt;drop table _TempTable;&lt;BR /&gt;drop table '$(TableName)';&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// CHANGE 1: Update these blocks of INLINE table loads to correspond to the names of the fields from your&lt;BR /&gt;// Shopping Cart app. The contents inside the $() in the record body of the INLINE load statements&lt;BR /&gt;// must match the names of the fields from your shopping cart app that the user makes selections on.&lt;BR /&gt;// If the database column name (lor QVD field name) for any of the selection fields has a different&lt;BR /&gt;// name, you need to alter the right hand side of the SET xxxx_COLNAME statement to reflect that&lt;BR /&gt;// field's corrresponding database column (or QVD field) name;&lt;BR /&gt;// &lt;BR /&gt;// All fields for On Demand are prefixed with od and the following to indicate selected or associated&lt;BR /&gt;// values&lt;BR /&gt;// ods = Selected values&lt;BR /&gt;// odo = Associated values&lt;BR /&gt;// odso = Selected/assocaited values&lt;BR /&gt;//&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SET EmpID ='';&lt;BR /&gt;OdagBinding:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;VAL&lt;BR /&gt;$(odo_EmpID){"quote": "", "delimiter": ""}&lt;BR /&gt;];&lt;BR /&gt;SET EmpID_COLNAME='EmpID';&lt;BR /&gt;CALL BuildValueList('EmpID', 'OdagBinding', 'VAL', 39); // 39 is for single quote wrapping values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE #2: Alter this with a leading 'WHERE &amp;lt;condition&amp;gt;' if you want your SQL statement (below)&lt;BR /&gt;// to have a non-changing WHERE clause in addition to the clauses that will be inserted&lt;BR /&gt;// by the shopping cart app (it is fine to leave it as is).&lt;/P&gt;
&lt;P&gt;SET WHERE_PART = '';&lt;/P&gt;
&lt;P&gt;// CHANGE 3: Update the list of field names here to reflect each of the field names variables you have on the&lt;BR /&gt;// left hand side (assignment target) of the first SET statement of the SET statement pairs in change&lt;BR /&gt;// 1 above. Note that in this case we're using ExtendQVDWhere which uses Qlik's mixmatch to build a &lt;BR /&gt;// where clause to test whether the inbound records match the conditions. If your the LOAD statement&lt;BR /&gt;// in which WHERE_PART is applied is querying a SQL database, use the 'ExtendSQLWhere' subroutine&lt;BR /&gt;// instead (and, of course, don't forget to include your database CONNECT statement).&lt;/P&gt;
&lt;P&gt;FOR EACH fldname IN 'EmpID'&lt;BR /&gt;LET vallist = $(fldname);&lt;BR /&gt;WHEN (IsNull(vallist)) LET vallist = '';&lt;BR /&gt;IF len(vallist) &amp;gt; 0 THEN&lt;BR /&gt;CALL ExtendQVDWhere('$(fldname)','vallist');&lt;BR /&gt;ENDIF&lt;BR /&gt;NEXT fldname&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;TRACE Generated WHERE clause: ;&lt;BR /&gt;TRACE $(WHERE_PART);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE # 4: Modify the list of columns (or QVD fields) you wish to load from your database table (or QVD)&lt;BR /&gt;// but leave the the $(WHERE_PART) portion of SQL (or LOAD) statement alone at the end.&lt;BR /&gt;// &lt;BR /&gt;// Note that you can have more than one of these dynamiclly alterered SELECT (or LOAD) statements&lt;BR /&gt;// by replicating the sections from CHANGE #2 thru this change #5 and customize which WHERE clauses&lt;BR /&gt;// will be inserted by altering the list of fields in the FOR EACH statement in Change #3.&lt;/P&gt;
&lt;P&gt;LET FOLDER='lib://DataFiles';&lt;BR /&gt;LET ORDERS_QVD='[$(FOLDER)/Orders.qvd](qvd)';&lt;BR /&gt;LET Employees_QVD='[$(FOLDER)/Employees.qvd](qvd)';&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Orders:&lt;BR /&gt;LOAD &lt;BR /&gt;OrderID, &lt;BR /&gt;CustomerID, &lt;BR /&gt;EmpID, &lt;BR /&gt;ShipperID, &lt;BR /&gt;FreightWeight, &lt;BR /&gt;OrderDate&lt;BR /&gt;FROM $(ORDERS_QVD) &lt;BR /&gt;$(WHERE_PART);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Employees:&lt;BR /&gt;LOAD&lt;BR /&gt;EmpID,&lt;BR /&gt;"First Name",&lt;BR /&gt;"Last Name",&lt;BR /&gt;DateOfBirth,&lt;BR /&gt;StartDate,&lt;BR /&gt;EndDate,&lt;BR /&gt;OfficeID,&lt;BR /&gt;JobTitle&lt;BR /&gt;FROM $(Employees_QVD)&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;for the 2 case)&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendQVDWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND mixmatch([$(ColName)],$(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE mixmatch([$(ColName)],$(Values))';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB ExtendSQLWhere(Name, ValVarName)&lt;BR /&gt;LET T = Name &amp;amp; '_COLNAME';&lt;BR /&gt;LET ColName = $(T);&lt;BR /&gt;LET Values = $(ValVarName);&lt;BR /&gt;IF len(Values) &amp;gt; 0 THEN&lt;BR /&gt;IF len(WHERE_PART) &amp;gt; 0 THEN&lt;BR /&gt;LET WHERE_PART = '$(WHERE_PART) AND $(ColName) IN ( $(Values) )';&lt;BR /&gt;ELSE&lt;BR /&gt;LET WHERE_PART = ' WHERE $(ColName) IN ( $(Values) )';&lt;BR /&gt;ENDIF&lt;BR /&gt;ENDIF&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// DO NOT ALTER THIS SUBROUTINE&lt;BR /&gt;SUB BuildValueList(VarName, TableName, ColName, QuoteChrNum)&lt;BR /&gt;IF ($(QuoteChrNum) = 0) THEN&lt;BR /&gt;LET LOADEXPR = 'Concat($(ColName),' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ELSE&lt;BR /&gt;LET CHREXPR = ' chr(' &amp;amp; '$(QuoteChrNum)' &amp;amp; ') ';&lt;BR /&gt;LET LOADEXPR = 'Concat( $(CHREXPR) &amp;amp; $(ColName) &amp;amp; $(CHREXPR)' &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ',' &amp;amp; chr(39) &amp;amp; ') AS CombinedData';&lt;BR /&gt;ENDIF&lt;BR /&gt;_TempTable:&lt;BR /&gt;LOAD $(LOADEXPR) Resident $(TableName);&lt;BR /&gt;Let vNoOfRows = NoOfRows('_TempTable');&lt;BR /&gt;IF $(vNoOfRows)&amp;gt; 0 THEN&lt;BR /&gt;LET $(VarName) = Peek('CombinedData',0,'_TempTable');&lt;BR /&gt;ENDIF&lt;BR /&gt;drop table _TempTable;&lt;BR /&gt;drop table '$(TableName)';&lt;BR /&gt;END SUB;&lt;/P&gt;
&lt;P&gt;// CHANGE 1: Update these blocks of INLINE table loads to correspond to the names of the fields from your&lt;BR /&gt;// Shopping Cart app. The contents inside the $() in the record body of the INLINE load statements&lt;BR /&gt;// must match the names of the fields from your shopping cart app that the user makes selections on.&lt;BR /&gt;// If the database column name (lor QVD field name) for any of the selection fields has a different&lt;BR /&gt;// name, you need to alter the right hand side of the SET xxxx_COLNAME statement to reflect that&lt;BR /&gt;// field's corrresponding database column (or QVD field) name;&lt;BR /&gt;// &lt;BR /&gt;// All fields for On Demand are prefixed with od and the following to indicate selected or associated&lt;BR /&gt;// values&lt;BR /&gt;// ods = Selected values&lt;BR /&gt;// odo = Associated values&lt;BR /&gt;// odso = Selected/assocaited values&lt;BR /&gt;//&lt;BR /&gt;//&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;SET EmpID ='';&lt;BR /&gt;OdagBinding:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;VAL&lt;BR /&gt;$(odo_EmpID){"quote": "", "delimiter": ""}&lt;BR /&gt;];&lt;BR /&gt;SET EmpID_COLNAME='EmpID';&lt;BR /&gt;CALL BuildValueList('EmpID', 'OdagBinding', 'VAL', 39); // 39 is for single quote wrapping values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE #2: Alter this with a leading 'WHERE &amp;lt;condition&amp;gt;' if you want your SQL statement (below)&lt;BR /&gt;// to have a non-changing WHERE clause in addition to the clauses that will be inserted&lt;BR /&gt;// by the shopping cart app (it is fine to leave it as is).&lt;/P&gt;
&lt;P&gt;SET WHERE_PART = '';&lt;/P&gt;
&lt;P&gt;// CHANGE 3: Update the list of field names here to reflect each of the field names variables you have on the&lt;BR /&gt;// left hand side (assignment target) of the first SET statement of the SET statement pairs in change&lt;BR /&gt;// 1 above. Note that in this case we're using ExtendQVDWhere which uses Qlik's mixmatch to build a &lt;BR /&gt;// where clause to test whether the inbound records match the conditions. If your the LOAD statement&lt;BR /&gt;// in which WHERE_PART is applied is querying a SQL database, use the 'ExtendSQLWhere' subroutine&lt;BR /&gt;// instead (and, of course, don't forget to include your database CONNECT statement).&lt;/P&gt;
&lt;P&gt;FOR EACH fldname IN 'EmpID'&lt;BR /&gt;LET vallist = $(fldname);&lt;BR /&gt;WHEN (IsNull(vallist)) LET vallist = '';&lt;BR /&gt;IF len(vallist) &amp;gt; 0 THEN&lt;BR /&gt;CALL ExtendQVDWhere('$(fldname)','vallist');&lt;BR /&gt;ENDIF&lt;BR /&gt;NEXT fldname&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;TRACE Generated WHERE clause: ;&lt;BR /&gt;TRACE $(WHERE_PART);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;// CHANGE # 4: Modify the list of columns (or QVD fields) you wish to load from your database table (or QVD)&lt;BR /&gt;// but leave the the $(WHERE_PART) portion of SQL (or LOAD) statement alone at the end.&lt;BR /&gt;// &lt;BR /&gt;// Note that you can have more than one of these dynamiclly alterered SELECT (or LOAD) statements&lt;BR /&gt;// by replicating the sections from CHANGE #2 thru this change #5 and customize which WHERE clauses&lt;BR /&gt;// will be inserted by altering the list of fields in the FOR EACH statement in Change #3.&lt;/P&gt;
&lt;P&gt;LET FOLDER='lib://DataFiles';&lt;BR /&gt;LET Employees_QVD='[$(FOLDER)/Employees.qvd](qvd)';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Employees:&lt;BR /&gt;LOAD&lt;BR /&gt;EmpID,&lt;BR /&gt;"First Name",&lt;BR /&gt;"Last Name",&lt;BR /&gt;DateOfBirth,&lt;BR /&gt;StartDate,&lt;BR /&gt;EndDate,&lt;BR /&gt;OfficeID,&lt;BR /&gt;JobTitle&lt;BR /&gt;FROM $(Employees_QVD)&lt;BR /&gt;;&lt;/P&gt;</description>
      <pubDate>Tue, 28 May 2024 07:31:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Dynamic-Views-from-Excel/m-p/2456826#M98534</guid>
      <dc:creator>Christos500</dc:creator>
      <dc:date>2024-05-28T07:31:20Z</dc:date>
    </item>
  </channel>
</rss>

