<?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 Select multiple row from tUniqrow Component in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372371#M135220</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;I have a situation where data is sorted based on some key and calculated the weighted sum.&lt;BR /&gt;e.g.&lt;BR /&gt;Line Key &amp;nbsp; &amp;nbsp;WeightedSum&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;&lt;BR /&gt;Now In output file I want to choose Line 2 &amp;amp; 3 against Key 1 and Line 5 for key 2.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I tried tuniqrow after using sort but tuniqrow does not support multiple output. Any suggestion?&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jul 2015 21:57:42 GMT</pubDate>
    <dc:creator>_AnonymousUser</dc:creator>
    <dc:date>2015-07-28T21:57:42Z</dc:date>
    <item>
      <title>Select multiple row from tUniqrow Component</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372371#M135220</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;I have a situation where data is sorted based on some key and calculated the weighted sum.&lt;BR /&gt;e.g.&lt;BR /&gt;Line Key &amp;nbsp; &amp;nbsp;WeightedSum&lt;BR /&gt;1 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;2 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;3 &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;4 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;BR /&gt;5 &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;BR /&gt;&lt;BR /&gt;Now In output file I want to choose Line 2 &amp;amp; 3 against Key 1 and Line 5 for key 2.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I tried tuniqrow after using sort but tuniqrow does not support multiple output. Any suggestion?&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2015 21:57:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372371#M135220</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2015-07-28T21:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple row from tUniqrow Component</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372372#M135221</link>
      <description>Is there any other way to achieve the same. Using different set of components?</description>
      <pubDate>Wed, 29 Jul 2015 00:58:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372372#M135221</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2015-07-29T00:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple row from tUniqrow Component</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372373#M135222</link>
      <description>hi Ayan,
&lt;BR /&gt;
&lt;BR /&gt;I don't understand your algorithm for the output.
&lt;BR /&gt;why 2&amp;amp;3 for key 1 , just 5 for key 2 . what are you expecting (fonctionaly) exactly ?
&lt;BR /&gt;
&lt;BR /&gt;regards
&lt;BR /&gt;laurent</description>
      <pubDate>Thu, 30 Jul 2015 09:02:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372373#M135222</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-30T09:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: Select multiple row from tUniqrow Component</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372374#M135223</link>
      <description>Is the algorithm meant to select all rows with the greatest WeightedSum for the key value? If so, you can do it like this. This is a little complicated, but is a really good example (the problem, not necessarily my explanation&amp;nbsp; 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MACn.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154443iC5B8CACEF3D12C6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MACn.png" alt="0683p000009MACn.png" /&gt;&lt;/span&gt;&amp;nbsp;) of how a tMap can be used to compare values across rows. 
&lt;BR /&gt; 
&lt;BR /&gt;1) Sort your data by Key and WeightedSum (in that order). Make sure that WeightedSum is ordered to be descending 
&lt;BR /&gt;2) Create a tMap and set 6 variables; lastKey, thisKey, lastWeightedSum, thisWeightedSum, firstWeightedSum and useRow. They must be in that order as variables are processed in the order in which they sit in the stack (top to bottom). 
&lt;BR /&gt;3) Connect your Key column to the "thisKey" variable and assign the value of "thisKey" to "lastKey". As "lastKey" is processed before "thisKey", in the first row it will be NULL. Variable values are stored between rows, so for the next row "lastKey" will hold the last Key value while "thisKey" will be given the current row value.&amp;nbsp; 
&lt;BR /&gt;4) Connect your WeightedSum column to the "thisWeightedSum" variable and assign the value of "thisWeightedSum" to "lastWeightedSum". As "lastWeightedSum" is processed before "thisWeightedSum", in the first row it will be NULL. Variable values are stored between rows, so for the next row "lastWeightedSum" will hold the last WeightedSum value while "thisWeightedSum" will be given the current row value. 
&lt;BR /&gt;5) For your "firstWeightedSum" variable, use the following logic..... 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;Var.lastKey==null ? Var.thisWeightedSum : Var.lastKey!= Var.thisKey ? Var.thisWeightedSum : Var.firstWeightedSum &lt;/PRE&gt; 
&lt;BR /&gt;This basically works out what the highest WeightedSum is (only if the WeightedSum is ordered in descending order) for a Key. This holds that value for the lifetime of the Key. This is used with the "useRow" variable to identify rows to keep. 
&lt;BR /&gt;5) In the value expression for the "useRow" variable, do the following. This variable must be a boolean variable. This assumes that WeightedSum and Key are numbers.... 
&lt;BR /&gt; 
&lt;BR /&gt; 
&lt;PRE&gt;Var.lastKey==null ? true : Var.lastKey!= Var.thisKey ? true : Var.firstWeightedSum==Var.thisWeightedSum ? true : false&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt; 
&lt;BR /&gt;This code uses the following logic.... 
&lt;BR /&gt; 
&lt;BR /&gt;a) If the "lastKey" is null, it must be the first row and as such we want this row (since the data is ordered by Key and WeightedSum, the first record is definitely required). 
&lt;BR /&gt;b) If the "lastKey" does not match the "thisKey", we know that the row is required. This indicates a new Key and the first record of a new Key group is always required. 
&lt;BR /&gt;c) If "thisKey" is equal to "lastKey" and "firstWeightedSum" is equal to "thisWeightedSum", we know that the record is required as the Key is the same as the last and shares the first (highest) WeightedSum. 
&lt;BR /&gt; 
&lt;BR /&gt;You can use the value of the "useRow" variable to filter your output rows. 
&lt;BR /&gt;&amp;nbsp;</description>
      <pubDate>Thu, 30 Jul 2015 10:58:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Select-multiple-row-from-tUniqrow-Component/m-p/2372374#M135223</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-07-30T10:58:29Z</dc:date>
    </item>
  </channel>
</rss>

