<?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 Top 1 per category in Quick Measures Gallery</title>
    <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/225700#M49</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes it can be valuable to simply show what the top performing products or customers are. The TopN filter in Power BI makes this an easy task but is bounded to a visual. To get the best performing category&amp;nbsp;in a single measure, this Quick calculation can be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the pbix, use the relative date slicer to see the top sold product changing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;How it works&lt;/H4&gt;
&lt;P&gt;Per category the selected measure is calculated, the TopN part will only select the first row based on the descending order for the selected measure over the categories.&amp;nbsp;When 2 rows in the categories share the same value, the lastnonblank selects the latest value based on the column sorting order. This can be changed to firstnonblank to select the first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Top 1 Productname for Sales&amp;nbsp;= &lt;BR /&gt;CALCULATE (&lt;BR /&gt; LASTNONBLANK ( 'Product'[Productname]; 1 );&lt;BR /&gt; FILTER ( TOPN ( 1; VALUES ( 'Product'[Productname] ); [Sales]; DESC ); TRUE () )&lt;BR /&gt;)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the value for the top 1 category, replace the LASTNONBLANK() with the {&lt;SPAN&gt;Base value&lt;/SPAN&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sales for Top 1 productname = &lt;BR /&gt;CALCULATE (&lt;BR /&gt; [Sales];&lt;BR /&gt; FILTER ( TOPN ( 1; VALUES ( 'Product'[Productname] ); [Sales]; DESC ); TRUE () )&lt;BR /&gt;)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the friendly label simply use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best product label = &lt;BR /&gt;"The best sold product is " &amp;amp; [Top 1 Productname for Sales] &amp;amp; " with " &amp;amp; FORMAT([Sales for Top 1 productname];"€ #,#") &amp;amp;" in sales"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4 id="toc-hId--1323657085"&gt;NAME:&lt;/H4&gt;
&lt;P&gt;Top 1&amp;nbsp;per category&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 id="toc-hId-419153250"&gt;DESCRIPTION:&lt;/H4&gt;
&lt;P&gt;Calculates the top 1 of the base value over the category&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 id="toc-hId--2133003711"&gt;PARAMETERS:&lt;/H4&gt;
&lt;P&gt;Name: Base value&lt;/P&gt;
&lt;P&gt;Tooltip:&amp;nbsp;The value that is used to determine the top 1&lt;/P&gt;
&lt;P&gt;Type: Numerical field / measure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name: Category&lt;/P&gt;
&lt;P&gt;Tooltip: The category in which you want to calculate the&amp;nbsp;top 1&lt;/P&gt;
&lt;P&gt;Type: Categorical field&lt;/P&gt;
&lt;H4 id="toc-hId--390193376"&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4 id="toc-hId-1352616959"&gt;DAX:&lt;/H4&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;Top 1 {Category} for {Base value} = &lt;BR /&gt;CALCULATE (&lt;BR /&gt; LASTNONBLANK ( &lt;SPAN&gt;{Category}&lt;/SPAN&gt;; 1 );&lt;BR /&gt; FILTER ( TOPN ( 1; VALUES ( &lt;SPAN&gt;{Category}&lt;/SPAN&gt; ); &lt;SPAN&gt;{Base value}&lt;/SPAN&gt;; DESC ); TRUE () )&lt;BR /&gt;)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiN2RmOWQ3MzctNDIwMC00N2U3LTk3ZjUtMTM3M2ZhYTI0N2NkIiwidCI6IjY2MjU3MWNmLWM5ZjgtNGQyOS1hYzcxLTA2N2E0NTY4MDExZCIsImMiOjh9&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Aug 2017 10:54:25 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-08-04T10:54:25Z</dc:date>
    <item>
      <title>Top 1 per category</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/225700#M49</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes it can be valuable to simply show what the top performing products or customers are. The TopN filter in Power BI makes this an easy task but is bounded to a visual. To get the best performing category&amp;nbsp;in a single measure, this Quick calculation can be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the pbix, use the relative date slicer to see the top sold product changing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;How it works&lt;/H4&gt;
&lt;P&gt;Per category the selected measure is calculated, the TopN part will only select the first row based on the descending order for the selected measure over the categories.&amp;nbsp;When 2 rows in the categories share the same value, the lastnonblank selects the latest value based on the column sorting order. This can be changed to firstnonblank to select the first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Examples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Top 1 Productname for Sales&amp;nbsp;= &lt;BR /&gt;CALCULATE (&lt;BR /&gt; LASTNONBLANK ( 'Product'[Productname]; 1 );&lt;BR /&gt; FILTER ( TOPN ( 1; VALUES ( 'Product'[Productname] ); [Sales]; DESC ); TRUE () )&lt;BR /&gt;)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the value for the top 1 category, replace the LASTNONBLANK() with the {&lt;SPAN&gt;Base value&lt;/SPAN&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sales for Top 1 productname = &lt;BR /&gt;CALCULATE (&lt;BR /&gt; [Sales];&lt;BR /&gt; FILTER ( TOPN ( 1; VALUES ( 'Product'[Productname] ); [Sales]; DESC ); TRUE () )&lt;BR /&gt;)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get the friendly label simply use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best product label = &lt;BR /&gt;"The best sold product is " &amp;amp; [Top 1 Productname for Sales] &amp;amp; " with " &amp;amp; FORMAT([Sales for Top 1 productname];"€ #,#") &amp;amp;" in sales"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4 id="toc-hId--1323657085"&gt;NAME:&lt;/H4&gt;
&lt;P&gt;Top 1&amp;nbsp;per category&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 id="toc-hId-419153250"&gt;DESCRIPTION:&lt;/H4&gt;
&lt;P&gt;Calculates the top 1 of the base value over the category&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H4 id="toc-hId--2133003711"&gt;PARAMETERS:&lt;/H4&gt;
&lt;P&gt;Name: Base value&lt;/P&gt;
&lt;P&gt;Tooltip:&amp;nbsp;The value that is used to determine the top 1&lt;/P&gt;
&lt;P&gt;Type: Numerical field / measure&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name: Category&lt;/P&gt;
&lt;P&gt;Tooltip: The category in which you want to calculate the&amp;nbsp;top 1&lt;/P&gt;
&lt;P&gt;Type: Categorical field&lt;/P&gt;
&lt;H4 id="toc-hId--390193376"&gt;&amp;nbsp;&lt;/H4&gt;
&lt;H4 id="toc-hId-1352616959"&gt;DAX:&lt;/H4&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE&gt;Top 1 {Category} for {Base value} = &lt;BR /&gt;CALCULATE (&lt;BR /&gt; LASTNONBLANK ( &lt;SPAN&gt;{Category}&lt;/SPAN&gt;; 1 );&lt;BR /&gt; FILTER ( TOPN ( 1; VALUES ( &lt;SPAN&gt;{Category}&lt;/SPAN&gt; ); &lt;SPAN&gt;{Base value}&lt;/SPAN&gt;; DESC ); TRUE () )&lt;BR /&gt;)&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="reportid hidden"&gt;eyJrIjoiN2RmOWQ3MzctNDIwMC00N2U3LTk3ZjUtMTM3M2ZhYTI0N2NkIiwidCI6IjY2MjU3MWNmLWM5ZjgtNGQyOS1hYzcxLTA2N2E0NTY4MDExZCIsImMiOjh9&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 10:54:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/225700#M49</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-08-04T10:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: Top 1 per category</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/376611#M113</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How will I defined two product name in the following wuery that you are given.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 04:32:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/376611#M113</guid>
      <dc:creator>mdaamirkhan</dc:creator>
      <dc:date>2018-03-15T04:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: Top 1 per category</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/377614#M114</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="35252" data-lia-user-login="mdaamirkhan" class="lia-mention lia-mention-user"&gt;mdaamirkhan&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want to accomplish? The names of the 2 products that have the highest sales?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because it's a measure you cannot return 2 rows. You should either contatenate the rows or use a table visual to filter on the top 2 based on sales. You could also create a New table with DAX where you can use the below FILTER() statement to reutn the top 2 products.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To concatenate the top 2 products you can use the formula below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Top2Concatenated =&lt;BR /&gt;CONCATENATEX (&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TOPN ( 2; VALUES ( 'Product'[Productname] ); [Sales]; DESC );&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Product'[Productname];&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ". "&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 08:51:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/377614#M114</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-03-16T08:51:35Z</dc:date>
    </item>
    <item>
      <title>Re: Top 1 per category</title>
      <link>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/1224773#M554</link>
      <description>&lt;P&gt;HI, I found this very useful - considering that i am an amateur, i am struggling to replicate the same for finding the TOP VALUE in the Subcategory, under the category determined as TOP category.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g. if the BASE VALUE is Total Sale -&amp;nbsp; Sum(Sale Value)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Brand A&amp;nbsp; &amp;nbsp; - $15000&lt;/P&gt;
&lt;P&gt;- Cat A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; $11000&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SubCat 1&amp;nbsp; &amp;nbsp; &amp;nbsp;- $3000&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SubCat 2&amp;nbsp; &amp;nbsp; &amp;nbsp;- $2000&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SubCat 3&amp;nbsp; &amp;nbsp; - $6000&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Cat B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&amp;nbsp; $4000&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Subcat 1 - $2500&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Subcat 3 - $1500&lt;BR /&gt;&lt;BR /&gt;Let's assume Brand A is the TOP 1 basis the Sale Value in Brands, then:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;-&amp;nbsp;under BRAND A,&amp;nbsp; CAT A is the TOP 1 category value&lt;BR /&gt;- Under Cat A, SubCat 3 is the TOP 1 Sub category value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can i achieve this, so that i can view this in a matrix or table visual ? Note that the table visual would list the following&lt;BR /&gt;- Customer ID&lt;/P&gt;
&lt;P&gt;- Total Sale Value of the customer&lt;/P&gt;
&lt;P&gt;- Customer TOP Brand&lt;/P&gt;
&lt;P&gt;- Total Sale value of the TOP Brand&lt;/P&gt;
&lt;P&gt;- Customer TOP Category&lt;/P&gt;
&lt;P&gt;- Total Sale Value of the TOP category&lt;BR /&gt;- Customer TOP Sub Category&lt;BR /&gt;- Total Sale Value of the TOP category&lt;BR /&gt;&lt;BR /&gt;I have a single fact table which features all the above.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jul 2020 13:10:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/Top-1-per-category/m-p/1224773#M554</guid>
      <dc:creator>srirambalan</dc:creator>
      <dc:date>2020-07-15T13:10:07Z</dc:date>
    </item>
  </channel>
</rss>

