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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
marsa
Frequent Visitor

Basket Analysis

Hi all,

 

I'm working on a basket report with the following model. I have 3 tables, the first one is a "product" table Product_code and Product_name as columns. The second is a customer table with the columns Customer_code, Customer_name, and Parent_customer_id. Finally, sales table product_code and customer_code columns.

 

I managed to copy a DAX formula from another post:

 

PurchaseBothProducts = 
var InitialPurchase = VALUES(Sales[Customer_code])
var CombinePurchase = CALCULATETABLE(VALUES(Sales[Customer_code]), ALL('Product'),
TREATAS(VALUES(Product_filter[Product_code]),Sales[Product_code]))

Return
IF( SELECTEDVALUE('Product'[Product_name]) = SELECTEDVALUE(Product_filter[Product_name]), BLANK(), COUNTROWS(INTERSECT(InitialPurchase,CombinePurchase)))

 

 

It works as you might expect, but now I'm running into an issue. The formula just takes into account the customers that have purchase product directly from us, but we have cases when a group of potential customers joints together to make a purchase, during the negotiation and sales everything is under just one customer therefore in the measure it will take it just like 1 customer when in reality it can be 10-15 customers together.

 

Is there a way to change the DAX measure or the PowerQuery process for it to measure as well as the "Indirect Customer"?

 

Thanks.

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

If I understand your situation correctly, I would propose the following.  Make another table with two columns - one with all your direct customer codes (individual customers and group customer codes), and the other for the indirect customer codes.  Each of your individual customers would have the same value in both columns.  Group customers would also have additional rows listed as one of the group.

 

You can then make a relationship (or not, if you want to use TREATAS) on the first column to your sales table on Customer code, but do you analysis on the 2nd column (VALUES() of it would include each customer whether they bought individually or as part of a group).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

hi  @marsa 

Sample data and expected output would help tremendously.
Please see this post regarding How to Get Your Question Answered Quickly:
https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
mahoneypat
Employee
Employee

If I understand your situation correctly, I would propose the following.  Make another table with two columns - one with all your direct customer codes (individual customers and group customer codes), and the other for the indirect customer codes.  Each of your individual customers would have the same value in both columns.  Group customers would also have additional rows listed as one of the group.

 

You can then make a relationship (or not, if you want to use TREATAS) on the first column to your sales table on Customer code, but do you analysis on the 2nd column (VALUES() of it would include each customer whether they bought individually or as part of a group).

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


This worked, I created the table and the relationship instead of using TREATAS just for convenience. Thanks for your help and sorry for the late response.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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