<?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: Show customer favorite brand in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106470#M90347</link>
    <description>&lt;P&gt;Perfect!! Thanks again &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2023 17:35:04 GMT</pubDate>
    <dc:creator>pedrohenriqueperna</dc:creator>
    <dc:date>2023-08-16T17:35:04Z</dc:date>
    <item>
      <title>Show customer favorite brand</title>
      <link>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106409#M90338</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to show the customer's favorite brand based on it's shopping frequency, but I'm not sure how to do it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data model is working, I can filter a certain customer and see all of it's purchases, but I need to show in a single line the most shopped brand (respecting the calendar filter selection).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I came close with this expression, but it only shows something if I select Year and Month, otherwise it's null:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If(Aggr(Rank(Count(key_produto_sku)), produto_marca) = 1, produto_marca)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Customer ID field = key_cliente_fornec&lt;/P&gt;
&lt;P&gt;product SKU = key_produto_sku&lt;/P&gt;
&lt;P&gt;product brand = produto_marca&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought maybe I could rank the counting of each SKU bought and aggregate it by it's respective brand, then if it's the first in the rank, show the brand name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if I'm in the right path. Does anyone have a clue?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 15:02:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106409#M90338</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2023-08-16T15:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Show customer favorite brand</title>
      <link>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106416#M90339</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;This is one of the trickier applications of AGGR(). I teach exactly the same solution as an exercise in my lecture on Set Analysis and AGGR() at the &lt;A href="https://masterssummit.com" target="_blank" rel="noopener"&gt;Masters Summit for Qlik&lt;/A&gt;. The complete explanation is perhaps too long for a forum message, but the bottom line is this:&lt;BR /&gt;&lt;BR /&gt;FirstSortedValue(&lt;SPAN&gt;key_cliente_fornec,&lt;/SPAN&gt; -&lt;SPAN&gt;Aggr(Rank(Count(key_produto_sku)), key_cliente_fornec, produto_marca))&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;See if this formula gives you the desired results.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Join us at the &lt;A href="https://masterssummit.com" target="_blank"&gt;Masters Summit for Qlik&lt;/A&gt; in Orlando or in Dublin to learn advanced Set Analysis, AGGR(), scripting, data modeling, performance, visualizations, and more - delivered by some of the best Qlik experts in the world!&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 15:11:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106416#M90339</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2023-08-16T15:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Show customer favorite brand</title>
      <link>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106448#M90342</link>
      <description>&lt;P&gt;Hi, Oleg!!&lt;BR /&gt;&amp;nbsp;Thanks for the quick reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The expression you provided didn't work at first, but I tweaked it a bit and it worked with the following:&lt;BR /&gt;&lt;BR /&gt;FirstSortedValue(produto_marca, Aggr(Rank(Count(key_produto_sku)), key_cliente_fornec, produto_marca))&lt;/P&gt;
&lt;P&gt;I changed the FirstSortedValue first argument to product_brand (it was returning the customer ID) and removed the "-" (not sure why).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It actually worked for most customers, but some return null(). While looking at these null records I think it's because there's a "draw" between one or more brands (e.g Calvin Klein was bought 2x at the same time Adidas was bought 2x). If that's true, it's actually correct as I'm trying to show only a single record and not a list.&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your help! &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you don't mind explaining, how does the "-" sign affects the Aggr function?&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 16:17:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106448#M90342</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2023-08-16T16:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Show customer favorite brand</title>
      <link>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106452#M90345</link>
      <description>&lt;P&gt;Good job tweaking the suggested solution!&lt;/P&gt;
&lt;P&gt;The "-" was my mistake - in your case you don't need it. We use it when we evaluate expressions like Sales, where the highest number is the best, hence we are reversing the direction, to get the "first sorted value" in the descending order. In your case, the Rank() function is already reversing the direction - the highest number gets the lowest Rank 1, so the formula works correctly without the minus.&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 16:22:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106452#M90345</guid>
      <dc:creator>Oleg_Troyansky</dc:creator>
      <dc:date>2023-08-16T16:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Show customer favorite brand</title>
      <link>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106470#M90347</link>
      <description>&lt;P&gt;Perfect!! Thanks again &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 17:35:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Show-customer-favorite-brand/m-p/2106470#M90347</guid>
      <dc:creator>pedrohenriqueperna</dc:creator>
      <dc:date>2023-08-16T17:35:04Z</dc:date>
    </item>
  </channel>
</rss>

