<?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: Calculate sale of other products in the same basket of a specific product in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1328105#M23470</link>
    <description>Wait a bit. It's not really that hard to write the correct measure but I have to find the time. Also, the table you've posted is not a representative one. Can you please send a better one with many more rows and many more different cases? For the time being, the table only shows baskets where all products are present. This, of course, is not what happens in real life. Also, for such a new table would you please give a description of what you want to see in each different case? That would certainly help to write the correct formula... Thanks.</description>
    <pubDate>Thu, 27 Aug 2020 08:02:19 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-08-27T08:02:19Z</dc:date>
    <item>
      <title>Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324363#M23336</link>
      <description>&lt;P&gt;Hello everyone,&lt;BR /&gt;&lt;BR /&gt;I have a transaction table with multiple products and sale numbers. I try to know the connection between one product and the remaining products, if they are likely to buy togethers. Im not good at english so I will give you a sample table and my expected result:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Transaction_ID&lt;/TD&gt;&lt;TD&gt;Product_ID&lt;/TD&gt;&lt;TD&gt;Sale&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HD001&lt;/TD&gt;&lt;TD&gt;P1&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HD001&lt;/TD&gt;&lt;TD&gt;P2&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HD001&lt;/TD&gt;&lt;TD&gt;P3&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HD002&lt;/TD&gt;&lt;TD&gt;P1&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HD002&lt;/TD&gt;&lt;TD&gt;P2&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;100&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;HD003&lt;/TD&gt;&lt;TD&gt;P3&lt;/TD&gt;&lt;TD&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get a pivot table which show me the sum of other product in the same basket as one specific products:&lt;BR /&gt;- P1:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;+ P2: 400 (300 in HD001, 100 in HD 002)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;+ P3: 200 (200 in HD001)&lt;/P&gt;&lt;P&gt;- P2:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;+ P1: 600&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;+ P3: 200&lt;/P&gt;&lt;P&gt;- P3:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;+ P1: 200&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;+ P2: 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you all be safe, thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 02:39:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324363#M23336</guid>
      <dc:creator>drbumba</dc:creator>
      <dc:date>2020-08-26T02:39:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324417#M23337</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255100" data-lia-user-login="drbumba" class="lia-mention lia-mention-user"&gt;drbumba&lt;/a&gt;&amp;nbsp;- Can you just use a matrix visualization and put transaction and product_id in the rows hierarchy?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 03:00:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324417#M23337</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2020-08-26T03:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324619#M23342</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="255100" data-lia-user-login="drbumba" class="lia-mention lia-mention-user"&gt;drbumba&lt;/a&gt; , are looking for Market Basket Analysis&lt;BR /&gt;&lt;A href="https://finance-bi.com/power-bi-basket-analysis/" target="_blank"&gt;https://finance-bi.com/power-bi-basket-analysis/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://businessintelligist.com/2017/03/27/market-basket-analysis-using-power-bi/" target="_blank"&gt;https://businessintelligist.com/2017/03/27/market-basket-analysis-using-power-bi/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.daxpatterns.com/usecases/market-basket-analysis/" target="_blank"&gt;https://www.daxpatterns.com/usecases/market-basket-analysis/&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://www.mssqltips.com/sqlservertip/5428/market-basket-analysis-in-r-and-power-bi/" target="_blank"&gt;https://www.mssqltips.com/sqlservertip/5428/market-basket-analysis-in-r-and-power-bi/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 05:13:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324619#M23342</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2020-08-26T05:13:44Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324620#M23343</link>
      <description>&lt;P&gt;I never thought of that. I will try and report back later, thanks &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Aug 2020 05:14:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1324620#M23343</guid>
      <dc:creator>drbumba</dc:creator>
      <dc:date>2020-08-26T05:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1327450#M23442</link>
      <description>&lt;P&gt;I tried the matrix visualiaztion but the outcome is different from what i expected. The value should be the sum of other product sale base on a specific items. The matrix filter out all other value of others products leaving only the chosen one. Do you have any other ideas.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 02:42:16 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1327450#M23442</guid>
      <dc:creator>drbumba</dc:creator>
      <dc:date>2020-08-27T02:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1327464#M23443</link>
      <description>&lt;P&gt;Thanks for your advices, the basket analysis is meaningful. But i still need the number result as I mentions, because we have other application requiring that calculation. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 02:45:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1327464#M23443</guid>
      <dc:creator>drbumba</dc:creator>
      <dc:date>2020-08-27T02:45:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1328105#M23470</link>
      <description>Wait a bit. It's not really that hard to write the correct measure but I have to find the time. Also, the table you've posted is not a representative one. Can you please send a better one with many more rows and many more different cases? For the time being, the table only shows baskets where all products are present. This, of course, is not what happens in real life. Also, for such a new table would you please give a description of what you want to see in each different case? That would certainly help to write the correct formula... Thanks.</description>
      <pubDate>Thu, 27 Aug 2020 08:02:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1328105#M23470</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-27T08:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1328825#M23495</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Assumptions:
// For a single product we want to see 
// the sum of all other products in the
// baskets in which the product exists.
// Bear in mind that you have not shown
// any dimensions, so I have to write
// a measure that will only work correctly
// with the one table presented. If
// your model is different from this one
// table, you'll have to modify the DAX
// accordingly.

[Other Prod Amount] =
IF( HASONEFILTER( T[Product_ID] ),
    // Since you've selected product P
    // the sum will be the total amount
    // for P across all the baskets.
    var __sumOfProductInBaskets =
        sum( T[Sale] )
    // This sum is the total for all the
    // baskets that are currently visible.
    var __sumOfAllBasketsWithTheProduct =
        CALCULATE(
            SUM( T[Sale] ),
            VALUES( T[Transaction_ID] ),
            ALL( T )
        )
    // This difference gives you the total
    // across the baskets in which P exists
    // excuding the value of P.
    var __delta =
        __sumOfAllBasketsWithTheProduct
            - __sumOfProductInBaskets
    var __result =
        If( __delta, __delta )
    return
        __result
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Aug 2020 12:06:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1328825#M23495</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-27T12:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1330761#M23568</link>
      <description>&lt;P&gt;Thank you for your reply. Unfortunately the end result im seeking is the amount for each pair it's generating. So the other dimension is other products. The end table should look like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;P1&lt;/TD&gt;&lt;TD&gt;P2&lt;/TD&gt;&lt;TD&gt;P3&lt;/TD&gt;&lt;TD&gt;Total&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;P1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;400&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;600&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;P2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;600&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;800&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;P3&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;TD&gt;300&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;500&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Your code did great job showing the total each product generate. But i cant see how much P1 make P2 sale for example.&lt;/P&gt;&lt;P&gt;I wrote a reply yesterday but it wasnt uploaded. Im sorry if making you inconvenient.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 04:01:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1330761#M23568</guid>
      <dc:creator>drbumba</dc:creator>
      <dc:date>2020-08-28T04:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate sale of other products in the same basket of a specific product</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1331512#M23577</link>
      <description>&lt;LI-CODE lang="csharp"&gt;// For the analysis you want you have to
// have at least 3 tables. The one with
// transactions (baskets) and one dimension
// with all the products, call it Products,
// and one other dimension called 'Other Products'.
// The latter will be a copy of the former.
// You'll connect Products to your Transactions table
// on ProductID and will leave the other
// table DISCONNECTED.
// Here is the relationship you need:
// Products[ProductID] 1 &amp;lt;-one-way- * Transactions[ProductID]
// You should hide all columns in Transactions.
// If you want, you could leave only the TransactionID
// column visible so that you can slice by transactions
// (baskets).
//
// Once the above is in place, you can write a measure:

[Other Product Sales] =
IF( HASONEVALUE( Products[ProductID] ),        
    var __otherProds =
        VALUES( 'Other Products'[ProductID] )
    return
        // This returns the value of the other products
        // in all the baskets in which the main product
        // can be found in the current context.
        CALCULATE(
            SUM( Transactions[Sale] ),
            // This filters the Transactions for
            // the other products
            TREATAS(
                __otherProds,
                Products[ProductID]
            ),
            // Restores the values of TransactionID's
            // visible in the current context (these
            // are the baskets in which the main product
            // can be found)
            VALUES( Transactions[TransactionID] ),
            // Removes all filters from Transactions
            ALL( Transactions )
        )
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 28 Aug 2020 09:31:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculate-sale-of-other-products-in-the-same-basket-of-a/m-p/1331512#M23577</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-08-28T09:31:06Z</dc:date>
    </item>
  </channel>
</rss>

