Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
MAAbdullah_47
Helper V
Helper V

Basket Analysis Both Items Total Sales

Dear Members,

I Created Items basket table from python script named (Basket Analysis) through power query successfully to calculate (support,lift and confidence) this table display the basket of each two items and measure the strength of relation through (support,lift and confidence) columns.

The table is Joined with Products table through the primary key (Product No) 1:m and of course products related to sales order (1:m),

Product Basket.JPG

The challange is I need to calculate the total sales of Both Items in the basket table (A,B) in all orders from table (sales) considering there is no relationship between (Basket analysis) and (Sales) Table, I created one measure to do this but it is not do it correctly :

M2M Total Sales =
                 CALCULATE(
                                      [Total Sales],
                                      FILTER(
                                                  Products,
                                                   CALCULATE( COUNTROWS( 'Basket Analysis') ) > 0
                                                   )
                                       )
I appreciate your help.

 

Note: Here is the Link of all resources.
https://drive.google.com/drive/folders/1Voi-Wr3IvbTptVbVui6VDQ-llIohZTbb?usp=sharing

4 REPLIES 4
Anonymous
Not applicable

I can't see the primary key (Product No) in the picture. I also can't see all the relationships to Basket Analysis (if there are any more than the ones shown). To do what you want, you have to have 2 relationships from Products to Basket Analysis: one to the first product, the other one to the other. One of them will be inactive. To calculate the amount for the first product you'll do nothing more than just return the sales amount [Total Sales]. For the other product, you'll need to use the USERELATIONSHIP function with some manipulation of filters on Products and Basket Analysis. This is not hard but you have to understand exactly what you want to do and remove the original filters.

Hi @Anonymous 

 

You comment: "you have to have 2 relationships from Products to Basket Analysis: one to the first product, the other one to the other. One of them will be inactive."

 

I did the Active Relationship BTW (Index from Products into Target Item P No from Basket analysis),

For the Inactive Relationship BTW (Index from Products into Second Item P No from Basket analysis).

 

I need your help to show me in the second (Inactive key) how to Use (USERELATIONSHIP ) with sales (Product forign key) on the absence of any relationship between both tables (Sales and Basket Analysis), (Basket Analysis Doesn't have primary key).

Thank you.

 

 

@Anonymous Target Itme P No is the foriegin key in (Basket Analysis) , I include the resources in the thread, For the second Item (Second Item P No) , For the Measure I Include it in the Thread, Cold you help me on what sort of Modification shall I do?

@Anonymous   Sorry The Primary Key is (Index) in Products table.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.