<?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: TOP 3 measure not working in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3274007#M121424</link>
    <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570958" data-lia-user-login="Rai_BI" class="lia-mention lia-mention-user"&gt;Rai_BI&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Measure expression should calculate based on the current row context. I haven't found any all function in your expression so they will be filtered to get result based current row category groups. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If current row context has aggregated less than three rows, it will be always displayed because the current dynamic rank has match the conditions.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;For this scenario, I'd like to suggest you add ALLSELECTED function in these expression calculations and try again:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TOP 3 SKU v2 =
VAR Tab1 =
    FILTER (
        SUMMARIZE (
            ALLSELECTED ( 'Products - 8097' ),
            'Products - 8097'[id],
            "@Rank", [Rank]
        ),
        [@Rank] &amp;lt;= 3
    )
RETURN
    CALCULATE (
        SUM ( 'fSales - 8027'[Total USD] ),
        FILTER (
            ALLSELECTED ( 'Products - 8097' ),
            'Products - 8097'[id] IN SELECTCOLUMNS ( Tab1, "ID", [id] )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Jun 2023 06:20:44 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-06-08T06:20:44Z</dc:date>
    <item>
      <title>TOP 3 measure not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3270396#M121191</link>
      <description>&lt;P&gt;Hello everyone, I need to clarify a doubt.&lt;/P&gt;&lt;P&gt;I need to make a measure following the two steps below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1st Find out which are the ID codes of the products that are the TOP 3 biggest in sales of the company;&lt;/P&gt;&lt;P&gt;2nd Calculate sales by filtering these ID codes found in the previous step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to do all the steps above in one single code. In my data model there are two related tables, a fact table called "Sales - 8027" and a dimension table called "Products - 8097".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did tests on two practically identical measures, but only one works even though I don't attend to the two steps mentioned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first measure had to create a physical table in my data model called "TOP 3" containing the product codes that are the TOP 3. This physical table was made with the following code:&lt;/P&gt;&lt;P&gt;TOP 3 =&lt;BR /&gt;VAR&lt;BR /&gt;Tab1 =&lt;BR /&gt;FILTER(&lt;BR /&gt;SUMMARIZE('Products - 8097','Products - 8097'[id],"@Rank",[Rank]),&lt;BR /&gt;[@Rank] &amp;lt;= 3&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;/P&gt;&lt;P&gt;SUMMARIZE(Tab1,'dProducts - 8097'[id])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I did the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Top 3 sku v1 =&lt;BR /&gt;CALCULATE(&lt;BR /&gt;SUM('Sales - 8027'[Total USD]),&lt;BR /&gt;FILTER('Products - 8097','Products - 8097'[id] IN VALUES('TOP 3'[id])))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked, after creating a physical table and then creating a measure, the result came out as I expected, but I wanted to create everything in a single measure to avoid creating many tables in the model, as mentioned in steps 1 and 2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I did it all in a single code as below:&lt;/P&gt;&lt;P&gt;TOP 3 SKU v2 =&lt;BR /&gt;VAR&lt;BR /&gt;Tab1 =&lt;BR /&gt;FILTER(&lt;BR /&gt;SUMMARIZE('Products - 8097','Products - 8097'[id],"@Rank",[Rank]),&lt;BR /&gt;[@Rank] &amp;lt;= 3&lt;BR /&gt;)&lt;BR /&gt;VAR Tab2 = SUMMARIZE(Tab1,'Products - 8097'[id])&lt;/P&gt;&lt;P&gt;RETURN&lt;/P&gt;&lt;P&gt;CALCULATE(&lt;BR /&gt;SUM('fSales - 8027'[Total USD]),&lt;BR /&gt;FILTER('Products - 8097','Products - 8097'[id] IN Tab2)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;This measure did not work, instead of returning sales of only the TOP 3 products, it returns sales of all products. I don't understand why this happens. Why does the measure "Top 3 sku v1" work but "TOP 3 Sku v2" does not work? Can anyone explain?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;If anyone has a different suggestion for achieving this goal I'd be happy to see it.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jun 2023 12:07:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3270396#M121191</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2023-06-06T12:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: TOP 3 measure not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3274007#M121424</link>
      <description>&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;HI&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570958" data-lia-user-login="Rai_BI" class="lia-mention lia-mention-user"&gt;Rai_BI&lt;/a&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Measure expression should calculate based on the current row context. I haven't found any all function in your expression so they will be filtered to get result based current row category groups. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;If current row context has aggregated less than three rows, it will be always displayed because the current dynamic rank has match the conditions.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;For this scenario, I'd like to suggest you add ALLSELECTED function in these expression calculations and try again:&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;TOP 3 SKU v2 =
VAR Tab1 =
    FILTER (
        SUMMARIZE (
            ALLSELECTED ( 'Products - 8097' ),
            'Products - 8097'[id],
            "@Rank", [Rank]
        ),
        [@Rank] &amp;lt;= 3
    )
RETURN
    CALCULATE (
        SUM ( 'fSales - 8027'[Total USD] ),
        FILTER (
            ALLSELECTED ( 'Products - 8097' ),
            'Products - 8097'[id] IN SELECTCOLUMNS ( Tab1, "ID", [id] )
        )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="tahoma,arial,helvetica,sans-serif"&gt;Xiaoxin Sheng&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 06:20:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3274007#M121424</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-08T06:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: TOP 3 measure not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3279634#M121788</link>
      <description>&lt;P&gt;It didn't work as expected. In fact, the general total value is returning the sum of the TOP 3 products, but it is not returning the individual value of each of the TOP 3. I need to know the value of each of the TOP 3 products.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 13:29:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3279634#M121788</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2023-06-12T13:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: TOP 3 measure not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3281065#M121880</link>
      <description>&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="570958" data-lia-user-login="Rai_BI" class="lia-mention lia-mention-user"&gt;Rai_BI&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;&lt;A href="http://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;How to Get Your Question Answered Quickly&amp;nbsp;&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Regards,&lt;/P&gt;
&lt;P style="margin: 0in; font-family: tahoma; font-size: 11.0pt;"&gt;Xiaoxin Sheng&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 07:21:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3281065#M121880</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-06-13T07:21:12Z</dc:date>
    </item>
    <item>
      <title>Re: TOP 3 measure not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3281785#M121911</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;I created a file to exemplify, because I cannot share the original file because it contains sensitive data. The link to download :&amp;nbsp;&lt;A href="https://we.tl/t-QKY402CEdC" target="_blank"&gt;https://we.tl/t-QKY402CEdC&lt;/A&gt;&lt;BR /&gt;I can´t attach a file here&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Jun 2023 13:35:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/TOP-3-measure-not-working/m-p/3281785#M121911</guid>
      <dc:creator>Rai_BI</dc:creator>
      <dc:date>2023-06-13T13:35:01Z</dc:date>
    </item>
  </channel>
</rss>

