<?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: expression help please in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441021#M485476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi al,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; i want to store input value to backend like qvd or something.i am getting input from excel file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 May 2013 14:27:06 GMT</pubDate>
    <dc:creator />
    <dc:date>2013-05-14T14:27:06Z</dc:date>
    <item>
      <title>expression help please</title>
      <link>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441018#M485473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have a weighted average expression here that I wanted to only include most current tests.&amp;nbsp; I've been using MAX(TestDate) to get most current test in other aggr functions that do simple counts, but am having trouble putting it into a weighted average expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(aggr(SUM(TestValue)/Count(UserId), UserId, TestName, Year))/Count(DISTINCT UserId)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Working from the inside out, this expression takes the average TestValue for each individual User AGGR(SUM(TestValue)/Count(UserID), UserId, TestName, Year) then totals them up and divides by the total number of users (SUM(aggr...))/Count(DISTINCT UserId)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of average test value for each individual user, I want it to work with the most recent test value for each individual user for a given test and year.&amp;nbsp; I've tried sticking MAX(TestDate) in a variety of places with syntax that seemed to make sense, but I am not getting sensible results yet.&amp;nbsp; I believe only the inner part, AGGR(SUM(TestValue)/Count(UserID), UserId, TestName, Year), needs to be changed.&amp;nbsp; I would ultimately like to average out the most current testvalues of the individual users.&amp;nbsp; (Instead of average out the average testvalues of the individual users.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Help!&amp;nbsp; Thanks! -Steve&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PS&amp;gt; This is in the expressions field of a straight table.&amp;nbsp; Anyone with a good idea of how to bring that function over to the script instead is welcome to post that.&amp;nbsp; I'll give correct answer to whichever one gets the job done.&amp;nbsp; (I know formula is preferable to have in script for performance reasons as well.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 19:43:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441018#M485473</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-05-08T19:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: expression help please</title>
      <link>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441019#M485474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Steve&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It looks like you need the firstsortedvalue() function. To get the latest value by User use -TestDate as the sort weight:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SUM(aggr(firstsortedvalue(TestValue,-1*TestDate), UserId, TestName, Year))/Count(DISTINCT UserId)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are right, it will work way better in the script. You can use firstsortedvalue in the script too, I would create a separate ke yof unique Users/testname / year (if not already) and join onto it your calculation grouped by user with the first sorted value for each.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EG&lt;/P&gt;&lt;P&gt;something like&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AvgTable:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;Autonumber(UserId&amp;amp;TestName&amp;amp;Year) as KEY,&lt;/P&gt;&lt;P&gt; UserId, &lt;/P&gt;&lt;P&gt;TestName,&lt;/P&gt;&lt;P&gt; Year,&lt;/P&gt;&lt;P&gt;firstsortedvalue(TestValue,-1*TestDate) as latestvalue&lt;/P&gt;&lt;P&gt;resident Activity_Data&lt;/P&gt;&lt;P&gt;group by UserId, TestName, Year;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if this helps,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Erica&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 22:02:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441019#M485474</guid>
      <dc:creator />
      <dc:date>2013-05-08T22:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: expression help please</title>
      <link>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441020#M485475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, my boss says this worked for him when he tried it in one of his scripts.&amp;nbsp; We were ambushed by other tasks and I didn't get to test it myself, but my boss is happy with it so correct answer to you. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2013 14:23:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441020#M485475</guid>
      <dc:creator>stevelord</dc:creator>
      <dc:date>2013-05-14T14:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: expression help please</title>
      <link>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441021#M485476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi al,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; i want to store input value to backend like qvd or something.i am getting input from excel file.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 May 2013 14:27:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/expression-help-please/m-p/441021#M485476</guid>
      <dc:creator />
      <dc:date>2013-05-14T14:27:06Z</dc:date>
    </item>
  </channel>
</rss>

