<?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 DAX Help - complex calculation in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4362228#M173183</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I am encountering a roadblock in the DAX code I am trying to develop and would appreciate any guidance or support!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is a picture of the work in progress (see below). The first level of the matrix is the promotion description. The next level drills down to the individual items in that promotion. The goal of the report is to compare items sold on promotion against that same item's total sales. There are two measures that we need for the matrix:&lt;BR /&gt;&lt;BR /&gt;Promotion Units: shows how many items sold on promotion&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Total Units Sold: needs to show total unit sales for an item. As you can see we have a test measure that shows the total units sold which ignores whether or not a unit sold on promo. As long as &amp;gt;1 of the item sold on promo, we get the total unit sales. The problem is, I am unable to get this to aggregate at the promotion description level. The current measure titled total units sold is incorrect. The correct value should be 1391 for fresh fruit banana and as a total at the description level.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;The data model is a star schema with transactions being the main fact table. There are three other dimensions being used: date, promotion, and item. Here is a picture of the model:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;An item is on promotion if it has a promotion key in the transaction table. If it is null than the item is not included in the promotion. In this example only the top row would be counted as an item sold on promotion.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a way for the measure total units sold to aggregate the total units of any item that falls under a promo description. Is there a way to do this with DAX?&lt;BR /&gt;&lt;BR /&gt;Hopefully that description makes sense. Thanks in advance for any help!&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2025 23:46:05 GMT</pubDate>
    <dc:creator>BlueRanger</dc:creator>
    <dc:date>2025-01-13T23:46:05Z</dc:date>
    <item>
      <title>DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4362228#M173183</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I am encountering a roadblock in the DAX code I am trying to develop and would appreciate any guidance or support!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Here is a picture of the work in progress (see below). The first level of the matrix is the promotion description. The next level drills down to the individual items in that promotion. The goal of the report is to compare items sold on promotion against that same item's total sales. There are two measures that we need for the matrix:&lt;BR /&gt;&lt;BR /&gt;Promotion Units: shows how many items sold on promotion&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Total Units Sold: needs to show total unit sales for an item. As you can see we have a test measure that shows the total units sold which ignores whether or not a unit sold on promo. As long as &amp;gt;1 of the item sold on promo, we get the total unit sales. The problem is, I am unable to get this to aggregate at the promotion description level. The current measure titled total units sold is incorrect. The correct value should be 1391 for fresh fruit banana and as a total at the description level.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;The data model is a star schema with transactions being the main fact table. There are three other dimensions being used: date, promotion, and item. Here is a picture of the model:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;An item is on promotion if it has a promotion key in the transaction table. If it is null than the item is not included in the promotion. In this example only the top row would be counted as an item sold on promotion.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need a way for the measure total units sold to aggregate the total units of any item that falls under a promo description. Is there a way to do this with DAX?&lt;BR /&gt;&lt;BR /&gt;Hopefully that description makes sense. Thanks in advance for any help!&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 23:46:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4362228#M173183</guid>
      <dc:creator>BlueRanger</dc:creator>
      <dc:date>2025-01-13T23:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4362630#M173203</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="579837" data-lia-user-login="BlueRanger" class="lia-mention lia-mention-user"&gt;BlueRanger&lt;/a&gt;&amp;nbsp;check example how it is implemented with DAX.DO, Promotion table structure on &lt;A href="https://dax.do/2StCoHjNe7daD2/" target="_self"&gt;link&lt;/A&gt;. Check also part relatioships with your model (it would be the best to have start and end date of promotion).&lt;/P&gt;
&lt;P&gt;On this &lt;A href="https://dax.do/9BLjUl5QndmFds/" target="_self"&gt;link&lt;/A&gt; it is example how to calculate sales without discount.&lt;/P&gt;
&lt;P&gt;Hope this help&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 06:29:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4362630#M173203</guid>
      <dc:creator>some_bih</dc:creator>
      <dc:date>2025-01-14T06:29:06Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4363394#M173234</link>
      <description>&lt;P&gt;I think you could create a measure like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Total Units Sold =
SUMX (
    KEEPFILTERS ( SUMMARIZE ( Transactions, Item[Item Key] ) ),
    CALCULATE ( COUNTROWS ( Transactions ) )
)
&lt;/LI-CODE&gt;
&lt;P&gt;This assumes that the item in your matrix is coming from the Items table.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 13:54:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4363394#M173234</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2025-01-14T13:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4363732#M173244</link>
      <description>&lt;P&gt;Thank you for everyone's help. I am still running into the same issue, unfortunately. I'm providing some sample data to illustrate the issue further, this includes a data schema, and desired output.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Transactions&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Business Date&lt;/TD&gt;&lt;TD&gt;Item Pack PK&lt;/TD&gt;&lt;TD&gt;Promotion Detail PK&lt;/TD&gt;&lt;TD&gt;Units Sold&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2025&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/2/2025&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;558&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/3/2025&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Promotions&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Promotion Description&lt;/TD&gt;&lt;TD&gt;Promotion Detail PK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bananas&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Items&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Item Name&lt;/TD&gt;&lt;TD&gt;Item Pack PK&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Fresh Fruit Banana&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Nuggies&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Date&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Date&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2025&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/2/2025&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/3/2025&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/4/2025&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/5/2025&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Desired Result (Matrix) in Power BI&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Model Schema&amp;nbsp;&lt;BR /&gt;&lt;BR /&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;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 17:31:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4363732#M173244</guid>
      <dc:creator>BlueRanger</dc:creator>
      <dc:date>2025-01-14T17:31:04Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4363736#M173245</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="555045" data-lia-user-login="some_bih" class="lia-mention lia-mention-user"&gt;some_bih&lt;/a&gt;&amp;nbsp;(love the name)! I am still running into issues. I do however have promotion start and end date in the promotions table. I provided some sample data below to illustrate what I am trying to accomplish. Start and end date is not included in the sample dataset.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 17:32:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4363736#M173245</guid>
      <dc:creator>BlueRanger</dc:creator>
      <dc:date>2025-01-14T17:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4364553#M173265</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="579837" data-lia-user-login="BlueRanger" class="lia-mention lia-mention-user"&gt;BlueRanger&lt;/a&gt;&amp;nbsp;Honestly, I do not feel well (some flue, I guess). I will not be able to check your case in following days. I am sorry.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jan 2025 07:39:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4364553#M173265</guid>
      <dc:creator>some_bih</dc:creator>
      <dc:date>2025-01-15T07:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4365473#M173329</link>
      <description>No worries - I appreciate your time. I hope you feel better!</description>
      <pubDate>Wed, 15 Jan 2025 16:22:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4365473#M173329</guid>
      <dc:creator>BlueRanger</dc:creator>
      <dc:date>2025-01-15T16:22:20Z</dc:date>
    </item>
    <item>
      <title>Re: DAX Help - complex calculation</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4367859#M173419</link>
      <description>&lt;P&gt;Sorry, the totals for the desired result should actually be:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 16:45:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Help-complex-calculation/m-p/4367859#M173419</guid>
      <dc:creator>BlueRanger</dc:creator>
      <dc:date>2025-01-16T16:45:21Z</dc:date>
    </item>
  </channel>
</rss>

