<?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: DAX calculation help! in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3844796#M150284</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="384827" data-lia-user-login="mlmchilli" class="lia-mention lia-mention-user"&gt;mlmchilli&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First of all, many thanks to&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp; for your very quick and effective replies, and I will give some additions below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the sample table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new measure to calculate the margin share.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Margin Share = 
var partn_ = SELECTEDVALUE('Table'[Partners])
VAR Margin = DIVIDE(SUM('Table'[Revenue]), SUM('Table'[Total cost]))
VAR BaseMargin = 0.2
VAR UpperMargin = 0.4
VAR ExcessMargin = MAX(0, Margin - UpperMargin)
VAR SharedExcess = ExcessMargin / 2

RETURN
IF(partn_ = "A", 
    IF(Margin &amp;lt;= 0.4, BaseMargin * SUM('Table'[Total cost]), BaseMargin * SUM('Table'[Total cost]) + SharedExcess * SUM('Table'[Total cost])),
    IF(Margin &amp;lt;= 0.4, (Margin - BaseMargin) * SUM('Table'[Total cost]), BaseMargin * SUM('Table'[Total cost]) + SharedExcess * SUM('Table'[Total cost]))
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3.Drag the measure into the table visual. The result is shown below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this 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;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 17 Apr 2024 09:11:05 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2024-04-17T09:11:05Z</dc:date>
    <item>
      <title>DAX calculation help!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3840962#M150164</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping somebody can point me in the right direction with a DAX query that I need to be able to solve but can't quite get me head around.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We have a fact table at a day granularity where a product has total cost and revenue metrics. I need to be able to calculate a margin share of the total cost i.e. revenue/total cost and then share the margin between two partners based on rules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Partner A must get at least 20% margin.&lt;/P&gt;&lt;P&gt;Partner B then gets anyting over 20% margin up until 40%&lt;/P&gt;&lt;P&gt;The margin over 40% is shared equally by A &amp;amp; B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, for example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product A on Jan 1 2024 has TotalCost 1000 and Revenue 300 = 30% margin&lt;/P&gt;&lt;P&gt;Partner A gets&amp;nbsp; 200, Partner B gets 100&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product B on Jan 1 2024 has TotalCost 1000 and Revenue 390 = 39% margin&lt;/P&gt;&lt;P&gt;Partner A gets&amp;nbsp; 200, Partner B gets 190&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product C on Jan 1 2024 has TotalCost 1000 and Revenue 400 = 40% margin&lt;/P&gt;&lt;P&gt;Partner A gets&amp;nbsp; 200, Partner B gets 200&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Product D on Jan 1 2024 has TotalCost 1000 and Revenue 540 = 54% margin&lt;/P&gt;&lt;P&gt;Partner A gets&amp;nbsp; 270, Partner B gets 270&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance or help on this would be very much appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 10:12:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3840962#M150164</guid>
      <dc:creator>mlmchilli</dc:creator>
      <dc:date>2024-04-16T10:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculation help!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3842695#M150223</link>
      <description>&lt;P&gt;Please provide sample data that covers your issue or question &lt;STRONG&gt;completely&lt;/STRONG&gt;, in a &lt;STRONG&gt;usable&lt;/STRONG&gt; format (not as a screenshot).&lt;BR /&gt;&lt;BR /&gt;Do not include sensitive information or anything not related to the issue or question. &lt;BR /&gt;&lt;BR /&gt;If you are unsure how to upload data please refer to &lt;A href="https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216&lt;/A&gt; &lt;BR /&gt;&lt;BR /&gt;Please show the expected outcome based on the sample data you provided. &lt;BR /&gt;&lt;BR /&gt;Want faster answers? &lt;A href="https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523" target="_blank"&gt;https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2024 21:45:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3842695#M150223</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-04-16T21:45:30Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculation help!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3844796#M150284</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="384827" data-lia-user-login="mlmchilli" class="lia-mention lia-mention-user"&gt;mlmchilli&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;First of all, many thanks to&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="100342" data-lia-user-login="lbendlin" class="lia-mention lia-mention-user"&gt;lbendlin&lt;/a&gt;&amp;nbsp; for your very quick and effective replies, and I will give some additions below:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1.Create the sample table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2.Create the new measure to calculate the margin share.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Margin Share = 
var partn_ = SELECTEDVALUE('Table'[Partners])
VAR Margin = DIVIDE(SUM('Table'[Revenue]), SUM('Table'[Total cost]))
VAR BaseMargin = 0.2
VAR UpperMargin = 0.4
VAR ExcessMargin = MAX(0, Margin - UpperMargin)
VAR SharedExcess = ExcessMargin / 2

RETURN
IF(partn_ = "A", 
    IF(Margin &amp;lt;= 0.4, BaseMargin * SUM('Table'[Total cost]), BaseMargin * SUM('Table'[Total cost]) + SharedExcess * SUM('Table'[Total cost])),
    IF(Margin &amp;lt;= 0.4, (Margin - BaseMargin) * SUM('Table'[Total cost]), BaseMargin * SUM('Table'[Total cost]) + SharedExcess * SUM('Table'[Total cost]))
)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3.Drag the measure into the table visual. The result is shown below.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Wisdom Wu&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If this 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;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 09:11:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3844796#M150284</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-04-17T09:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculation help!</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3853304#M150546</link>
      <description>&lt;LI-SPOILER&gt;Many thanks Wisdom! This pointed me in the right direction so much appreciated!&lt;/LI-SPOILER&gt;</description>
      <pubDate>Fri, 19 Apr 2024 10:06:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculation-help/m-p/3853304#M150546</guid>
      <dc:creator>mlmchilli</dc:creator>
      <dc:date>2024-04-19T10:06:24Z</dc:date>
    </item>
  </channel>
</rss>

