<?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 TableName() function is not working with IterNo, RecNo etc in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453717#M98199</link>
    <description>&lt;P&gt;So there is a logic to get TableName list:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;for i=0 to nooftables()-1
  TableList:
  Load
    tablename($(i)) as TableName
  Autogenerate 1;
next i&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Now I want to simplify this to a one load with Autogenerate and TableName() function returns NULL():&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TableList:
Load
  tablename(RecNo()-1) as TableName,
  RecNo(),
  RowNo()
Autogenerate nooftables();&lt;/LI-CODE&gt;
&lt;P&gt;Also have tried with Preceding Load and still nothing:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TableList:
Load
  tablename(rec_no-1) as TableName,
  rec_no,
  row_no;
Load
  RecNo() as rec_no,
  RowNo() as row_no
Autogenerate nooftables();&lt;/LI-CODE&gt;
&lt;P&gt;It seems like a bug to me - TableName() responds only if we put integer or recalculated variable there.&lt;BR /&gt;Any thoughts on this?&lt;/P&gt;</description>
    <pubDate>Fri, 17 May 2024 14:33:52 GMT</pubDate>
    <dc:creator>Firefly_cam</dc:creator>
    <dc:date>2024-05-17T14:33:52Z</dc:date>
    <item>
      <title>TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453717#M98199</link>
      <description>&lt;P&gt;So there is a logic to get TableName list:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;for i=0 to nooftables()-1
  TableList:
  Load
    tablename($(i)) as TableName
  Autogenerate 1;
next i&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Now I want to simplify this to a one load with Autogenerate and TableName() function returns NULL():&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TableList:
Load
  tablename(RecNo()-1) as TableName,
  RecNo(),
  RowNo()
Autogenerate nooftables();&lt;/LI-CODE&gt;
&lt;P&gt;Also have tried with Preceding Load and still nothing:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TableList:
Load
  tablename(rec_no-1) as TableName,
  rec_no,
  row_no;
Load
  RecNo() as rec_no,
  RowNo() as row_no
Autogenerate nooftables();&lt;/LI-CODE&gt;
&lt;P&gt;It seems like a bug to me - TableName() responds only if we put integer or recalculated variable there.&lt;BR /&gt;Any thoughts on this?&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 14:33:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453717#M98199</guid>
      <dc:creator>Firefly_cam</dc:creator>
      <dc:date>2024-05-17T14:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453744#M98200</link>
      <description>&lt;P&gt;I don't know if you can call it a bug. The function is coded to accept literal values for the parameter, not expressions. So I suppose changing it to accept an expression may be considered more of an "enhancement".&lt;/P&gt;
&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 15:28:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453744#M98200</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2024-05-17T15:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453746#M98201</link>
      <description>&lt;P&gt;I think tablename() expects an "existing" value like a variable would be providing because each variable is evaluated before the statement/object. By applying a function or even field-values it requires a processing.&lt;/P&gt;
&lt;P&gt;I don't know if there are any special requirements to access this kind of meta-data or if it's rather a bug within the underlying function - maybe in regard to the scope/validity of variables/parameter. From my point of view is the "pain" with this behaviour not heavy because the for loop is also quite readable.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 15:36:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453746#M98201</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-05-17T15:36:22Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453747#M98202</link>
      <description>&lt;P&gt;Hi Rob, thanks for reply&lt;BR /&gt;I called it as a bug because similar subject FieldName() function works fine both with Preceding Load and IterNo() etc&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TableFieldList:
Load
   Table,
   FieldName(IterNo(),Table) as FName
While IterNo() &amp;lt;= NoOfFields;
Load
   tablename(0) as Table,
   NoOfFields(tablename(0)) as NoOfFields
Autogenerate 1;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 20:17:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453747#M98202</guid>
      <dc:creator>Firefly_cam</dc:creator>
      <dc:date>2024-05-17T20:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453753#M98203</link>
      <description>&lt;P&gt;Hi Marcus,&lt;BR /&gt;For Loop works just fine but it generates a lot of useless rows in script_log file. Besides it is significantly slower (minimum twice) than Autogenerate.&lt;BR /&gt;Here's a simple example of generating 2 tables 10mil rows each&lt;BR /&gt;For Loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;For i=1 to 10000
  Table1:
  Load
       Chr( Floor(rand() * 26) + 65) as %Key,
       RecNo() as RecNo1
       Autogenerate 1000;

  Table2:
  Load
       Chr( Floor(rand() * 26) + 65) as %Key,
       RecNo() as RecNo2
       Autogenerate 1000;
Next i&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One load with autogenerate 10 mils&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table1:
Load
     Chr( Floor(rand() * 26) + 65) as %Key,
     RecNo() as RecNo1
     Autogenerate 10000000;

Table2:
Load
     Chr( Floor(rand() * 26) + 65) as %Key,
     RecNo() as RecNo2
     Autogenerate 10000000;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 20:18:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453753#M98203</guid>
      <dc:creator>Firefly_cam</dc:creator>
      <dc:date>2024-05-17T20:18:27Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453799#M98210</link>
      <description>&lt;P&gt;I see your point.&amp;nbsp; I can't actually find TableName() or NoOfTables() in the current documentation, so I don't know what Qlik's intention is.&amp;nbsp; The last doc reference I could find is from QV 11 that shows number is to be a literal:&lt;/P&gt;
&lt;P class="p1"&gt;TableName( 'TableNumber' )&lt;/P&gt;
&lt;P class="p1"&gt;You could try reporting it (and the missing doc) as a bug and see where it gets to.&lt;/P&gt;
&lt;P class="p1"&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Fri, 17 May 2024 21:05:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453799#M98210</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2024-05-17T21:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453817#M98216</link>
      <description>&lt;P&gt;The documentation of tablenumber() is found here:&amp;nbsp;&lt;A href="https://help.qlik.com/en-US/sense/May2024/Subsystems/Hub/Content/Sense_Hub/Scripting/TableFunctions/table-functions.htm" target="_blank"&gt;https://help.qlik.com/en-US/sense/May2024/Subsystems/Hub/Content/Sense_Hub/Scripting/TableFunctions/table-functions.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;And here: &lt;A href="https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/Scripting/TableFunctions/table-functions.htm" target="_blank"&gt;https://help.qlik.com/en-US/qlikview/May2023/Subsystems/Client/Content/QV_QlikView/Scripting/TableFunctions/table-functions.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 18 May 2024 06:06:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2453817#M98216</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2024-05-18T06:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454256#M98277</link>
      <description>&lt;P&gt;My mistake on the doc. I was thrown off because TableName() does not appear in the left-hand TOC.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rwunderlich_0-1716217147883.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166434i712713EF9B5B65C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rwunderlich_0-1716217147883.png" alt="rwunderlich_0-1716217147883.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2024 14:59:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454256#M98277</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2024-05-20T14:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454447#M98297</link>
      <description>&lt;P&gt;Of course are outside load-loops significantly slower as inside load-loops especially by high amounts of iterations because of the multiple jumps of finishing a load and initializing the next one - each one with n milli/micro-seconds latency.&lt;/P&gt;
&lt;P&gt;But by querying the existing tables within a data-model there are usually 5 - 20 tables which won't cause any performance issue if they are queried with a for-loop. You are right that all outside load-loops are resulting in badly readable log-entries but the log-file itself is rather ugly and probably seldom used regularly (personally nearly never during the development - my common mistakes of typos or not set/removed commas, quotes and so on are quite obvious - and within the production I jump only to the end to go to the error).&lt;/P&gt;
&lt;P&gt;Nevertheless if you want to analyse it more you may use the script-log analyser from Rob and Clever:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://qlikviewcookbook.com/recipes/?download_search=log#squelch-taas-accordion-shortcode-content-6" target="_blank"&gt;Search Recipes | Qlikview Cookbook&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marcus_sommer_0-1716276478024.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166469i75CEF9B445715B24/image-size/medium?v=v2&amp;amp;px=400" role="button" title="marcus_sommer_0-1716276478024.png" alt="marcus_sommer_0-1716276478024.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Beside this I could imagine that tablename() isn't a "real" function else only a reference respectively a pointer to the RAM address and declaring it as function is just a way to make it accessible.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 07:31:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454447#M98297</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-05-21T07:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454482#M98301</link>
      <description>&lt;P&gt;Thanks for your comments, all are relevant indeed&lt;BR /&gt;&lt;BR /&gt;As for the topic itself, I kept playing with it and appears the evaluations can be done within both TableName() and TableNumber() functions and they work as expected. Counter functions and any operations with the field values are not working and this seems to be an undocumented limitation for both functions. Closing this topic with accepting this limitation as a fact.&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-05-21 at 13.45.58.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/166474i2C5BDEF0D204109F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-05-21 at 13.45.58.png" alt="Screenshot 2024-05-21 at 13.45.58.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 08:26:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454482#M98301</guid>
      <dc:creator>Firefly_cam</dc:creator>
      <dc:date>2024-05-21T08:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454664#M98324</link>
      <description>&lt;P&gt;Just a hint to the documentation which doesn't contained an information anymore which has probably not (entirely) changed n the years and this is that (all) table/field-functions expects (normally) a string as table/field-name and not a normal table/field-call - means also a call of:&lt;/P&gt;
&lt;P&gt;tablenumber('My Table')&lt;/P&gt;
&lt;P&gt;If I remember correctly this was a must in the old days. Nowadays it might be often working without it because the context of a call defined the interpretation ... but honestly I'm not sure that this is always true.&lt;/P&gt;
&lt;P&gt;Beside this I played a bit more with the matter and found some kind of workaround by using:&lt;/P&gt;
&lt;P&gt;t1: load recno()-1 as R autogenerate nooftables();&lt;BR /&gt;t2: load evaluate('tablename(' &amp;amp; R &amp;amp; ')') as TableName, R resident t1;&lt;/P&gt;
&lt;P&gt;t3: &lt;BR /&gt;load evaluate('tablename(' &amp;amp; RecNo &amp;amp; ')') as TableName;&lt;BR /&gt;load recno() -1 as RecNo autogenerate nooftables();&lt;/P&gt;
&lt;P&gt;which means it worked by a resident load as well as by a preceding but not including recno() - within the evaluate - only recno() will work!&lt;/P&gt;
&lt;P&gt;Someone with ideas why it behaved as it behaved?&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 11:58:48 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454664#M98324</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2024-05-21T11:58:48Z</dc:date>
    </item>
    <item>
      <title>Re: TableName() function is not working with IterNo, RecNo etc</title>
      <link>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454682#M98326</link>
      <description>&lt;P&gt;Thanks for the workaround and in fact this even works like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Tab2:
load evaluate('tablename(' &amp;amp; RowNo()-1 &amp;amp; ')') as TableName
autogenerate nooftables();

or

Tab2:
load evaluate('tablename(' &amp;amp; RecNo()-1 &amp;amp; ')') as TableName
autogenerate nooftables();&lt;/LI-CODE&gt;
&lt;P&gt;Idk why and the IterNo() still doesn't work even like this.&lt;/P&gt;</description>
      <pubDate>Tue, 21 May 2024 12:33:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/TableName-function-is-not-working-with-IterNo-RecNo-etc/m-p/2454682#M98326</guid>
      <dc:creator>Firefly_cam</dc:creator>
      <dc:date>2024-05-21T12:33:28Z</dc:date>
    </item>
  </channel>
</rss>

