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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare 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
September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors