<?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: Concatenate results from FirstSortedValue in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008098#M1221616</link>
    <description>&lt;P&gt;Have a look at this solution, which you should be able to adapt to your scenario:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/New-to-Qlik-Sense/Concatenate-Results-if-FirstSortedValue-is-a-Tie/m-p/1330420" target="_blank"&gt;https://community.qlik.com/t5/New-to-Qlik-Sense/Concatenate-Results-if-FirstSortedValue-is-a-Tie/m-p/1330420&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Nov 2022 10:45:18 GMT</pubDate>
    <dc:creator>Or</dc:creator>
    <dc:date>2022-11-23T10:45:18Z</dc:date>
    <item>
      <title>Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2007966#M1221608</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am having difficulties writing expressions where the answers need to concatenate results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a (small) dataset to illustrate :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[CATEGORY, LOCATION, DATE]&lt;/P&gt;
&lt;P&gt;Car, Paris, 02/03/2022&lt;/P&gt;
&lt;P&gt;Boat, Madrid, 08/03/2022&lt;/P&gt;
&lt;P&gt;Car, Paris, 03/04/2022&lt;/P&gt;
&lt;P&gt;Boat, London, 05/04/2022&lt;/P&gt;
&lt;P&gt;Car, Barcelona, 07/04/2022&lt;/P&gt;
&lt;P&gt;Plane, New York, 10/04/2022&lt;/P&gt;
&lt;P&gt;Car, Barcelona, 12/05/2022&lt;/P&gt;
&lt;P&gt;Car, Sydney, 12/05/2022&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here are the questions I need answered :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1 - Where was the last car sold ?&lt;/P&gt;
&lt;P&gt;As you can see this brings two results. Barcelona and Sydney. Using the following doesn't work, since it can only return one answer :&lt;/P&gt;
&lt;P&gt;FirstSortedValue({&amp;lt;[Category] = {'Car'} &amp;gt;} Location, - [Date])&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried adding a concat() but get a "no nested expression" syntaxe error. I guess I should wrap it inside an Aggr() but can't figure out how.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Where were the majority of the cars sold ?&lt;/P&gt;
&lt;P&gt;Same thing here. Two results should be returned, Paris and Barcelona. I've tried a few expressions but can't find a suitable, working one, that concatenates the results if there are more than one (brace yourselves, you will probably find this very poorly written) :&lt;/P&gt;
&lt;P&gt;FirstSortedValue(Aggr(Concat(distinct [Location], ','), [Location], [Category]), Aggr(Sum([Category] = 'Car'), [Location], [Category]))&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help to figure out how these should be written would be greatly appreciated!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 07:58:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2007966#M1221608</guid>
      <dc:creator>BergsonF</dc:creator>
      <dc:date>2022-11-23T07:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008084#M1221614</link>
      <description>&lt;P&gt;Try this.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;=Concat(Aggr(FirstSortedValue({&amp;lt;CATEGORY={'Car'}&amp;gt;}LOCATION,-DATE),LOCATION),', ')&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 23 Nov 2022 10:30:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008084#M1221614</guid>
      <dc:creator>BrunPierre</dc:creator>
      <dc:date>2022-11-23T10:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008090#M1221615</link>
      <description>&lt;P&gt;Just tried it and it does concatenate, but all the locations. It does not provide only the 'latest' event, the FirstSortedValue does not seem to come into play...&lt;/P&gt;
&lt;P&gt;Tried :&lt;/P&gt;
&lt;P&gt;FirstSortedValue(Aggr({&amp;lt;CATEGORY = {'Car'} &amp;gt;} Concat(distinct LOCATION, ','), LOCATION), -DATE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Syntax is OK, but no result. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 10:54:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008090#M1221615</guid>
      <dc:creator>BergsonF</dc:creator>
      <dc:date>2022-11-23T10:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008098#M1221616</link>
      <description>&lt;P&gt;Have a look at this solution, which you should be able to adapt to your scenario:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/New-to-Qlik-Sense/Concatenate-Results-if-FirstSortedValue-is-a-Tie/m-p/1330420" target="_blank"&gt;https://community.qlik.com/t5/New-to-Qlik-Sense/Concatenate-Results-if-FirstSortedValue-is-a-Tie/m-p/1330420&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Nov 2022 10:45:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008098#M1221616</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2022-11-23T10:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008623#M1221633</link>
      <description>&lt;P&gt;Edit : the following works and answers my second question "Which is the top city for Car sales?"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concat(distinct Aggr(if(Count({&amp;lt;[CATEGORY] ={'Car'} &amp;gt;} [LOCATION]) = Max(TOTAL Aggr(Count({&amp;lt;[CATEGORY] = {'Car'} &amp;gt;} [LOCATION]),&amp;nbsp;[LOCATION])), [LOCATION]), [LOCATION]), ',')&lt;/P&gt;
&lt;P&gt;I will try to start from there to find a way to answer my first question :" Where were the last cars sold?"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks Or, for pointing me in the right direction!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 09:54:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008623#M1221633</guid>
      <dc:creator>BergsonF</dc:creator>
      <dc:date>2022-11-24T09:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008730#M1221641</link>
      <description>&lt;P&gt;Returning to this...&lt;/P&gt;
&lt;P&gt;FirstSortedValue({&amp;lt;[CATEGORY ] = {'Car'} &amp;gt;} LOCATION , - [DATE])&lt;/P&gt;
&lt;P&gt;^^ This expression works properly, but only if there is one result to return.&lt;/P&gt;
&lt;P&gt;Concat(FirstSortedValue({&amp;lt;[CATEGORY] = {'Car'} &amp;gt;} LOCATION, - [DATE]), ',')&lt;/P&gt;
&lt;P&gt;^^ Does not work because of the "no nested expression" error&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Concat(Aggr(FirstSortedValue({&amp;lt;[CATEGORY ] = {'Car'} &amp;gt;} LOCATION, - [DATE), LOCATION), ',')&lt;/P&gt;
&lt;P&gt;^^ Seems to work but returns all the locations of my dataset.&lt;/P&gt;
&lt;P&gt;Qliksense language is really obscure for me, but if I had to perform this operation in python or Java, I would first find the latest entries (FirstSortedValue for 'Car'), and then, IF there are several possible results, concatenate them.&lt;/P&gt;
&lt;P&gt;So I tried going the other way around with :&lt;/P&gt;
&lt;P&gt;FirstSortedValue({&amp;lt;[CATEGORY]={'Car'}&amp;gt;} Aggr(Concat(distinct LOCATION, ','), LOCATION), -DATE)&lt;/P&gt;
&lt;P&gt;... And got nothing.&lt;/P&gt;
&lt;P&gt;Starting to get frustrated at this point &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 10:53:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008730#M1221641</guid>
      <dc:creator>BergsonF</dc:creator>
      <dc:date>2022-11-24T10:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008887#M1221651</link>
      <description>&lt;P&gt;Trying to "think out of the box", I tried an other method :&lt;/P&gt;
&lt;P&gt;1. Find the last date for any car sale&lt;/P&gt;
&lt;P&gt;2. Find and concatenate sales matching that date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I started with creating a measure called 'LastDateCar' :&lt;/P&gt;
&lt;P&gt;Date(FirstSortedValue(distinct {&amp;lt;[CATEGORY] = {'Car'} &amp;gt;} DATE, -DATE), 'DD/MM/YYYY')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result is '12/05/2022'. So far so good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I wrote this short expression, just to check if I was able to concatenate the locations properly :&lt;/P&gt;
&lt;P&gt;Concat(distinct Aggr(if(DATE = '12/05/2022', LOCATION, 'Error'), LOCATION), ',')&lt;/P&gt;
&lt;P&gt;I got the following return 'Sydney, Barcelona'. Great.&lt;/P&gt;
&lt;P&gt;However, when I tried to use my custom measure 'LastDateCar' :&lt;/P&gt;
&lt;P&gt;Concat(distinct Aggr(if(DATE = LastDateCar , LOCATION, 'Error'), LOCATION), ',')&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I get all the locations where cars were sold, along with 'Error'...&lt;/P&gt;
&lt;P&gt;Sigh...&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 15:28:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2008887#M1221651</guid>
      <dc:creator>BergsonF</dc:creator>
      <dc:date>2022-11-24T15:28:44Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate results from FirstSortedValue</title>
      <link>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2009152#M1221666</link>
      <description>&lt;P&gt;I found the solution :&lt;/P&gt;
&lt;P&gt;1. Where was the last car sold ?&lt;BR /&gt;In case there is more than one result, here is how I did it.&lt;BR /&gt;Created a 'variable' (not a 'measure') called 'LastCarSold' :&lt;BR /&gt;Date(FirstSortedValue (distinct {&amp;lt;[CATEGORY] = {'Car'} &amp;gt;} DATE, -DATE), 'DD/MM/YYYY')&lt;/P&gt;
&lt;P&gt;And then called this variable in the expression :&lt;BR /&gt;Concat(distinct {&amp;lt;[CATEGORY] = 'Car' &amp;gt; + &amp;lt;DATE = {'$(=$(LastCarSold))'} &amp;gt;} LOCATION, ',')&lt;/P&gt;
&lt;P&gt;I first get the last date for a specific event, and I concatenate the locations for these specific events that happened at the same date. Not optimal, but it works.&lt;/P&gt;
&lt;P&gt;2. Where were most cars sold ?&lt;BR /&gt;I used the expression from the link provided earlier.&lt;BR /&gt;Concat(Distinct Aggr(if(Count({&amp;lt;[CATEGORY] ={'Car'} &amp;gt;} LOCATION) = Max(TOTAL Aggr(Count({&amp;lt;[CATEGORY] ={'Car'} &amp;gt;} LOCATION), LOCATION)), LOCATION), LOCATION), ',')&lt;/P&gt;
&lt;P&gt;Thanks for your help guys!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Nov 2022 10:12:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Concatenate-results-from-FirstSortedValue/m-p/2009152#M1221666</guid>
      <dc:creator>BergsonF</dc:creator>
      <dc:date>2022-11-25T10:12:27Z</dc:date>
    </item>
  </channel>
</rss>

