<?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: average Aggr function in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969326#M959353</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Samuel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My educated guess is that your Time field actually contains a timestamp, i.e. behind the scenes it's tracking both the date and the time. It's impossible to tell from what you've shared so far, it's just a hunch...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your script, if I'm right and you actually have a timestamp, you can create a true Time field like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Time(TimestampField-dayStart(TimestampField)) AS Time,&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If on the other hand QlikView isn't recognising your Time properly, it may be a text field. You can test this by the IsNum() function. Any properly interpreted time,timestamp or date would return 'True'. In that case, look at the definition of the Time#() function which allows you to easily convert a text time to a true time field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AM/PM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you pre-calculate your AM/PM dimension in the script, things will be a lot easier to debug &lt;EM&gt;and&lt;/EM&gt; you will deliver better performance rather than calculating this attribute unnecessarily on the fly (it's a static attribute, so no need for a front end calculated dimension).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, in the script, where ever the Time field sits, you can add an extra row like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;if(Time&amp;gt;time#('12','hh'),'PM','AM') AS [AM/PM]&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Jonas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 27 Oct 2015 16:02:25 GMT</pubDate>
    <dc:creator>JonasValleskog</dc:creator>
    <dc:date>2015-10-27T16:02:25Z</dc:date>
    <item>
      <title>average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969320#M959347</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;&lt;/P&gt;&lt;P&gt;can someone please take a look at the below, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the expressions belongs in a table with the following dimensions&lt;/P&gt;&lt;P&gt;Weekday(Date)&lt;/P&gt;&lt;P&gt;if(Time,&amp;gt;12:00,'PM','AM')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the expressions should count all the minutes for each day and then average that table placing the values in the appropriate cell depending on the weekday and time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;=avg(aggr(&lt;/P&gt;&lt;P&gt;count({$&amp;lt; ArbitrationInput.Group.rOOk = {"&amp;lt;$(=only({$&amp;lt; [/rec/parameter] = {'rOff'},[/#text] = {'CommonParameters'},[Config] = {'Live'}&amp;gt;}[/rec/parameter/curval]))"} &amp;gt;} Timestamp),&lt;/P&gt;&lt;P&gt;Date))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what seems to happen in when i dont filter only the AM is shown unless i filter to PM. i think something is wrong with the time element and all data is getting lumped into the AM unless i specify otherwise.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 10:41:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969320#M959347</guid>
      <dc:creator>samuel_brierley</dc:creator>
      <dc:date>2015-10-27T10:41:16Z</dc:date>
    </item>
    <item>
      <title>Re: average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969321#M959348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi samuel, you can try using it as number in the if, 12:00 is half a day so it's numerac representation is '0.5':&lt;/P&gt;&lt;P&gt;if(Time&amp;gt;0.5,'PM','AM') // '&amp;gt;' counts 12 o'clock as 'AM', '&amp;gt;=' will count 12 o'clock as 'PM'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 10:44:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969321#M959348</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-10-27T10:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969322#M959349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks for the reply Rubin however the problem is the same &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/sad.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 10:46:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969322#M959349</guid>
      <dc:creator>samuel_brierley</dc:creator>
      <dc:date>2015-10-27T10:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969323#M959350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have doubts if I understand it right, anyway you can try to add your dimensions to the Aggr:&lt;/P&gt;&lt;P&gt;=avg(aggr(&lt;/P&gt;&lt;P&gt;count({$&amp;lt; ArbitrationInput.Group.rOOk = {"&amp;lt;$(=only({$&amp;lt; [/rec/parameter] = {'rOff'},[/#text] = {'CommonParameters'},[Config] = {'Live'}&amp;gt;}[/rec/parameter/curval]))"} &amp;gt;} Timestamp),&lt;/P&gt;&lt;P&gt;WeekDayField, Date, AM/PM_Field))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 10:49:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969323#M959350</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2015-10-27T10:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969324#M959351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you have a grain mismatch here&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/qlik-blogpost/4418"&gt;Pitfalls of the Aggr function&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chart dimension Time is finer than aggr() dimension Date. You can try with an NODISTINCT qualifier to the aggr() function, but not sure if this will return correct values.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 10:53:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969324#M959351</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2015-10-27T10:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969325#M959352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;thanks swuehl thats certainly getting numbers through.&lt;/P&gt;&lt;P&gt;i feel a few hours of info checking are required but thanks &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 11:06:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969325#M959352</guid>
      <dc:creator>samuel_brierley</dc:creator>
      <dc:date>2015-10-27T11:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: average Aggr function</title>
      <link>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969326#M959353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Samuel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My educated guess is that your Time field actually contains a timestamp, i.e. behind the scenes it's tracking both the date and the time. It's impossible to tell from what you've shared so far, it's just a hunch...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In your script, if I'm right and you actually have a timestamp, you can create a true Time field like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;Time(TimestampField-dayStart(TimestampField)) AS Time,&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If on the other hand QlikView isn't recognising your Time properly, it may be a text field. You can test this by the IsNum() function. Any properly interpreted time,timestamp or date would return 'True'. In that case, look at the definition of the Time#() function which allows you to easily convert a text time to a true time field.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;AM/PM&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you pre-calculate your AM/PM dimension in the script, things will be a lot easier to debug &lt;EM&gt;and&lt;/EM&gt; you will deliver better performance rather than calculating this attribute unnecessarily on the fly (it's a static attribute, so no need for a front end calculated dimension).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, in the script, where ever the Time field sits, you can add an extra row like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;if(Time&amp;gt;time#('12','hh'),'PM','AM') AS [AM/PM]&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;Jonas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 Oct 2015 16:02:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/average-Aggr-function/m-p/969326#M959353</guid>
      <dc:creator>JonasValleskog</dc:creator>
      <dc:date>2015-10-27T16:02:25Z</dc:date>
    </item>
  </channel>
</rss>

