<?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 Need help with making dynamic selections with First sorted value in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Need-help-with-making-dynamic-selections-with-First-sorted-value/m-p/346567#M1172478</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning, I am having problems with mentioned expression, I am using the expression below to get most recent meter read and meter read a year ago.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FirstSortedValue(Meter_Reading,-Meter_Reading_Date,1)&lt;/P&gt;&lt;P&gt;FirstSortedValue(Meter_Reading,-Meter_Reading_Date,3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works on the assumption if there are 2 reads a year, this becomes wrong if more than one read is done a year (which happens a lot)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I have put 2 restrictions in the script to only load Meter reading type value of either 01 or 02 and meter reading reason being 01 or 02&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The diagram below shows how the data extracted when using first sorted value using my method becomes skewed, this happens&amp;nbsp; if above values don't fall in the 01 or 02 category.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="15716" alt="readings.JPG" class="jive-image" src="https://community.qlik.com/legacyfs/online/15716_readings.JPG" /&gt;&lt;/P&gt;&lt;P&gt;The latest read shows a read of 230 when using FirstSortedValue(Meter_Reading,-Meter_Reading_Date,1)&lt;/P&gt;&lt;P&gt;and 0 for FirstSortedValue(Meter_Reading,-Meter_Reading_Date,3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand why this is the case as it has ignored any rows with data that dont fit withing script restrictions and in this example I am only wanting the data that fits in the data for date 18.04.2012 and 18.10.2012. This will often change and have a number of reads between which may have a variety of values that dont fit above restrictions, this is making things very difficult&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am ideally looking for the latest read and a read a year back from that date that have the 01 or 02 restrictions, ive been pulling y hair out for weeks to get this to work, help would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Jun 2012 09:48:26 GMT</pubDate>
    <dc:creator />
    <dc:date>2012-06-11T09:48:26Z</dc:date>
    <item>
      <title>Need help with making dynamic selections with First sorted value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-making-dynamic-selections-with-First-sorted-value/m-p/346567#M1172478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Morning, I am having problems with mentioned expression, I am using the expression below to get most recent meter read and meter read a year ago.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FirstSortedValue(Meter_Reading,-Meter_Reading_Date,1)&lt;/P&gt;&lt;P&gt;FirstSortedValue(Meter_Reading,-Meter_Reading_Date,3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This works on the assumption if there are 2 reads a year, this becomes wrong if more than one read is done a year (which happens a lot)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also I have put 2 restrictions in the script to only load Meter reading type value of either 01 or 02 and meter reading reason being 01 or 02&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The diagram below shows how the data extracted when using first sorted value using my method becomes skewed, this happens&amp;nbsp; if above values don't fall in the 01 or 02 category.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="15716" alt="readings.JPG" class="jive-image" src="https://community.qlik.com/legacyfs/online/15716_readings.JPG" /&gt;&lt;/P&gt;&lt;P&gt;The latest read shows a read of 230 when using FirstSortedValue(Meter_Reading,-Meter_Reading_Date,1)&lt;/P&gt;&lt;P&gt;and 0 for FirstSortedValue(Meter_Reading,-Meter_Reading_Date,3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand why this is the case as it has ignored any rows with data that dont fit withing script restrictions and in this example I am only wanting the data that fits in the data for date 18.04.2012 and 18.10.2012. This will often change and have a number of reads between which may have a variety of values that dont fit above restrictions, this is making things very difficult&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am ideally looking for the latest read and a read a year back from that date that have the 01 or 02 restrictions, ive been pulling y hair out for weeks to get this to work, help would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 09:48:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-making-dynamic-selections-with-First-sorted-value/m-p/346567#M1172478</guid>
      <dc:creator />
      <dc:date>2012-06-11T09:48:26Z</dc:date>
    </item>
    <item>
      <title>Need help with making dynamic selections with First sorted value</title>
      <link>https://community.qlik.com/t5/QlikView/Need-help-with-making-dynamic-selections-with-First-sorted-value/m-p/346568#M1172479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Anyone?&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/cry.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jun 2012 11:53:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Need-help-with-making-dynamic-selections-with-First-sorted-value/m-p/346568#M1172479</guid>
      <dc:creator />
      <dc:date>2012-06-11T11:53:42Z</dc:date>
    </item>
  </channel>
</rss>

