<?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: Company with Maximum profit per state in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3614164#M139732</link>
    <description>&lt;P&gt;Thank you! It worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I need to show the info as a report, How do I do that?&lt;/P&gt;</description>
    <pubDate>Wed, 03 Jan 2024 22:17:00 GMT</pubDate>
    <dc:creator>deepak_d03</dc:creator>
    <dc:date>2024-01-03T22:17:00Z</dc:date>
    <item>
      <title>Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612120#M139639</link>
      <description>&lt;P&gt;Here is the sample data. For each state, I need to show the company having the maximum profit. (profit = premium written - losses paid - taxes paid).&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have so far and the output, but not sure how to proceed to include the Insurance company corresponds to the maximum profit.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;EVALUATE&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SUMMARIZECOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'IOWA'&lt;/SPAN&gt;&lt;SPAN&gt;[State]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"Max Profit"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;MAXX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'IOWA'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;'IOWA'&lt;/SPAN&gt;&lt;SPAN&gt;[Profit]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&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>Wed, 03 Jan 2024 03:19:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612120#M139639</guid>
      <dc:creator>deepak_d03</dc:creator>
      <dc:date>2024-01-03T03:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612329#M139647</link>
      <description>&lt;P&gt;hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="668384" data-lia-user-login="deepak_d03" class="lia-mention lia-mention-user"&gt;deepak_d03&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;as i understand your problem&amp;nbsp;&amp;nbsp;&lt;BR /&gt;below is my data and code for output as you want&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;data image&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;code&amp;nbsp;&lt;BR /&gt;just adjust column and table name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EVALUATE
ADDCOLUMNS(
    ALL('Table'[state]),
    
    "company name",
    CALCULATE(
        MIN('Table'[company name]),
        'Table'[profit]=MAXX( 
                          FILTER(
                            'Table',
                            'Table'[state]=EARLIER('Table'[state])
                           ),
                           'Table'[profit]
                        )
    ),
"profit",
 CALCULATE(max('Table'[profit]))
 )&lt;/LI-CODE&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;output image&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&lt;I&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;and don't forgot to give kudos&lt;/I&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 06:08:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612329#M139647</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2024-01-03T06:08:12Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612395#M139649</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="668384" data-lia-user-login="deepak_d03" class="lia-mention lia-mention-user"&gt;deepak_d03&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;for create new table in power bi use below formula&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Table 2 = 
ADDCOLUMNS( ALL('lowa'[state]),
  "company name", 
   var a = MAXX( FILTER('lowa', 'lowa'[state] = EARLIER('lowa'[state])),'lowa'[profit])
   RETURN
   MAXX( FILTER( 'lowa','lowa'[profit]=a),'lowa'[company name]),
   "profit",MAXX( FILTER('lowa', 'lowa'[state] = EARLIER('lowa'[state])),'lowa'[profit])
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Jan 2024 06:42:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612395#M139649</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2024-01-03T06:42:35Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612571#M139661</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="668384" data-lia-user-login="deepak_d03" class="lia-mention lia-mention-user"&gt;deepak_d03&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please try&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;EVALUATE
SUMMARIZECOLUMNS (
    'IOWA'[State],
    "Max Profit", MAXX ( 'IOWA', 'IOWA'[Profit] ),
    "Max Profit Company", MAXX ( TOPN ( 1, 'IOWA', 'IOWA'[Profit] ), 'IOWA'[Company Name] )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 03 Jan 2024 08:20:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612571#M139661</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2024-01-03T08:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612581#M139662</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;i am learn new thing from you that another use of TOPN() function&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 08:25:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612581#M139662</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2024-01-03T08:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612730#M139668</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="668384" data-lia-user-login="deepak_d03" class="lia-mention lia-mention-user"&gt;deepak_d03&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Please follow these steps:&lt;/STRONG&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Summarize the data by State, Company Name columns, filter the data with Ranking=1, assign to __ValueFilterDM0 variable.&lt;/LI&gt;
&lt;LI&gt;Summarize data by State, Company Name columns for __ValueFilterDM0 and assign to __DS0Core variable.&lt;/LI&gt;
&lt;LI&gt;Select the first 501 rows of data and assign them to the variable __DS0PrimaryWindowed, with "1" representing ascending order and "0" representing descending order.&lt;/LI&gt;
&lt;LI&gt;Display the data for __DS0PrimaryWindowed.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;STRONG&gt;The original data is as follows:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The DAX code is as follows:&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;DEFINE
	VAR __ValueFilterDM0 = 
		FILTER(
			KEEPFILTERS(
				SUMMARIZECOLUMNS(
					'IOWA'[State],
					'IOWA'[Company Name],
					"Profit", 'IOWA'[Profit],
					"Ranking", IGNORE('IOWA'[Ranking])
				)
			),
			[Ranking] = 1
		)

	VAR __DS0Core = 
		SUMMARIZECOLUMNS('IOWA'[State], 'IOWA'[Company Name], __ValueFilterDM0, "Profit", 'IOWA'[Profit])

	VAR __DS0PrimaryWindowed = 
		TOPN(501, __DS0Core, 'IOWA'[State], 1, [Profit], 0, 'IOWA'[Company Name], 1)

EVALUATE
	__DS0PrimaryWindowed

ORDER BY
	'IOWA'[State], [Profit] DESC, 'IOWA'[Company Name]&lt;/LI-CODE&gt;
&lt;P&gt;&lt;STRONG&gt;Run the result as follows:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yang&lt;BR /&gt;Community Support Team&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If there is any post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp;to help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know.&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Thanks a lot!&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 09:31:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3612730#M139668</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-01-03T09:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3614164#M139732</link>
      <description>&lt;P&gt;Thank you! It worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I need to show the info as a report, How do I do that?&lt;/P&gt;</description>
      <pubDate>Wed, 03 Jan 2024 22:17:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3614164#M139732</guid>
      <dc:creator>deepak_d03</dc:creator>
      <dc:date>2024-01-03T22:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3614517#M139742</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="668384" data-lia-user-login="deepak_d03" class="lia-mention lia-mention-user"&gt;deepak_d03&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create [Max profit] and [Max Profit Companies] as measures and place them along with IOWA[State] column in a table visual.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jan 2024 04:20:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3614517#M139742</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2024-01-04T04:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: Company with Maximum profit per state</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3624137#M140124</link>
      <description>&lt;P&gt;Thank you! It worked.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 00:07:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Company-with-Maximum-profit-per-state/m-p/3624137#M140124</guid>
      <dc:creator>deepak_d03</dc:creator>
      <dc:date>2024-01-09T00:07:22Z</dc:date>
    </item>
  </channel>
</rss>

