<?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: Setting and variable only once in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100909#M891645</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nishant,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; After your table is loaded we need to work out the avg value of &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Tenure_in_org then retrieve that value from wherever Qlikview is holding it and put it in a variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After loading the Resource table the value we're looking for doesn't yet exist in the data model. Your idea to apply the Avg to the field would be fine as an expression in an interface textbox when the entire load was completed but that approach is not open to us in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A simple way to do it is to create a temporary table with one field and one record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;TempAvg:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Load&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Sum(&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Tenure_in_org)/Count(&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Resource_Id) as &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;AvgOrgTenure&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;resident &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Resource;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-size: 13px; font-style: inherit; font-weight: inherit;"&gt;When this is done there will be a single value for the field AvgOrgTenure in the table TempAvg. I &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px;"&gt;didn't&lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-style: inherit; font-weight: inherit;"&gt; use the Avg function though I probably could have but I prefer to work it out as a sum divided by a count.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;The Peek function retrieves values from tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;I could have written out the Peek function using the full syntax and that would be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Peek('&lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;AvgOrgTenure',0,'&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;TempAvg&lt;/SPAN&gt;')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first parameter is the field name I'm interested in. NOTE: the field name with single quotes around it is style to use here. &lt;/P&gt;&lt;P&gt;The second parameter is a number that tells QlikView which record to go to to retrieve the value, 0 means get the value from the first record, 1 from the second , etc. The index starts from 0 not 1. You can put negative values in this parameter too, -1 means get the value from the last record, -2 means get the second last record, etc. The default is -1, get the value from the last record added to the table, so I left this parameter blank. &lt;/P&gt;&lt;P&gt;The third parameter allows us to specify the table to look in but this is only necessary if the field occurs in more than one table which would mean it would be a key field creating an association between tables and that is not the case here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Let &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;vAvgOrgTenure &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;= Peek('&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;AvgOrgTenure');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;places the value we are looking for into the variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Lastly we can drop the temporary table to keep thing tidy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Hope this makes things clear, if not let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Andrew&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 28 Aug 2016 08:41:47 GMT</pubDate>
    <dc:creator>effinty2112</dc:creator>
    <dc:date>2016-08-28T08:41:47Z</dc:date>
    <item>
      <title>Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100906#M891642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Is it possible to set a variable only once at the time of load.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am trying is to set the MEAN/AVG months in a variable, I need this value in chart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would have two values:&lt;/P&gt;&lt;P&gt;Tenure of the Employee in The organisation&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;Avg Tenure of all the employee&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am willing to chow this comparison in the chart.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can i achiever this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried Below in script editor, Thought this would just set once but&amp;nbsp; &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Resource:&lt;/P&gt;&lt;P&gt;LOAD DISTINCT Resource_Id, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Resource_Name,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Gender, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Role, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Level, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Primary_Skill, &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Is_Multiskilled,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DOJ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Round((date(Today(),'MM/DD/YYY')-date(DOJ,'MM/DD/YYYY'))/30) as Tenure_in_org,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit_Ind&lt;/P&gt;&lt;P&gt;FROM&lt;/P&gt;&lt;P&gt;&lt;C&gt;&lt;/C&gt;&lt;/P&gt;&lt;P&gt;(ooxml, embedded labels, table is Sheet1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set vAvgOrgTenure = 'Avg(Tenure_in_org)' ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100906#M891642</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100907#M891643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nishant,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TempAvg:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Sum(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Tenure_in_org)/Count(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Resource_Id) as &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;AvgOrgTenure&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;resident &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Resource;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;vAvgOrgTenure &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;= Peek('&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;AvgOrgTenure');&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Drop Table &lt;SPAN style="font-size: 13.3333px;"&gt;TempAvg;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Aug 2016 20:44:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100907#M891643</guid>
      <dc:creator>effinty2112</dc:creator>
      <dc:date>2016-08-27T20:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100908#M891644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Wow.. Thanks!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It worked like charm &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;Can you please explain this solution a bit. is it the RESIDENT keyword that made the difference. If yes, please let me know how.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 27 Aug 2016 23:29:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100908#M891644</guid>
      <dc:creator />
      <dc:date>2016-08-27T23:29:25Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100909#M891645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nishant,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; After your table is loaded we need to work out the avg value of &lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Tenure_in_org then retrieve that value from wherever Qlikview is holding it and put it in a variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After loading the Resource table the value we're looking for doesn't yet exist in the data model. Your idea to apply the Avg to the field would be fine as an expression in an interface textbox when the entire load was completed but that approach is not open to us in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A simple way to do it is to create a temporary table with one field and one record.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;TempAvg:&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Load&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;Sum(&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Tenure_in_org)/Count(&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Resource_Id) as &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;AvgOrgTenure&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;resident &lt;SPAN style="font-weight: inherit; font-style: inherit;"&gt;Resource;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="font-style: inherit; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;"&gt;&lt;SPAN style="font-size: 13px; font-style: inherit; font-weight: inherit;"&gt;When this is done there will be a single value for the field AvgOrgTenure in the table TempAvg. I &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px;"&gt;didn't&lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-style: inherit; font-weight: inherit;"&gt; use the Avg function though I probably could have but I prefer to work it out as a sum divided by a count.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;The Peek function retrieves values from tables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;I could have written out the Peek function using the full syntax and that would be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-style: inherit; font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-weight: inherit;"&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Peek('&lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;AvgOrgTenure',0,'&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;TempAvg&lt;/SPAN&gt;')&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The first parameter is the field name I'm interested in. NOTE: the field name with single quotes around it is style to use here. &lt;/P&gt;&lt;P&gt;The second parameter is a number that tells QlikView which record to go to to retrieve the value, 0 means get the value from the first record, 1 from the second , etc. The index starts from 0 not 1. You can put negative values in this parameter too, -1 means get the value from the last record, -2 means get the second last record, etc. The default is -1, get the value from the last record added to the table, so I left this parameter blank. &lt;/P&gt;&lt;P&gt;The third parameter allows us to specify the table to look in but this is only necessary if the field occurs in more than one table which would mean it would be a key field creating an association between tables and that is not the case here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;Let &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;vAvgOrgTenure &lt;/SPAN&gt;&lt;SPAN style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;= Peek('&lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;AvgOrgTenure');&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;places the value we are looking for into the variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Lastly we can drop the temporary table to keep thing tidy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Hope this makes things clear, if not let me know.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Kind regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: inherit; font-weight: inherit; line-height: 1.5em;"&gt;Andrew&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Aug 2016 08:41:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100909#M891645</guid>
      <dc:creator>effinty2112</dc:creator>
      <dc:date>2016-08-28T08:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100910#M891646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thaks alot Andrew. For the solution as well as detailed explanation &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&amp;nbsp; its always fun learning&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2016 15:49:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100910#M891646</guid>
      <dc:creator />
      <dc:date>2016-08-29T15:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100911#M891647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nishant,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you're satisfied that your question has been answered please consider marking my answer as correct.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2016 16:08:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100911#M891647</guid>
      <dc:creator>effinty2112</dc:creator>
      <dc:date>2016-08-29T16:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Setting and variable only once</title>
      <link>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100912#M891648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nishant,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thanks a lot for marking my answer correct.Please disregard my message before this one&lt;SPAN style="font-size: 13.3333px;"&gt; I wasn't aware you had done so already&lt;/SPAN&gt;. I'm very glad I was able to help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Aug 2016 16:10:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Setting-and-variable-only-once/m-p/1100912#M891648</guid>
      <dc:creator>effinty2112</dc:creator>
      <dc:date>2016-08-29T16:10:16Z</dc:date>
    </item>
  </channel>
</rss>

