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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Frequent bought products

I need help with one of my projects on frequent bought products:

  1. Customer who bought product X&Y also bought Z. If slicer selection is X and Y the table visual should reflect the frequently bought product as X, Y and Z with the order quantity and Total Price
  2. Dax to find out Average order value of products selected in a slicer.

My requirement is to fetch products which are bought in same order frequently with the selected products in the slicer. Similar to the Recommendation Engine in Ecommerce sites which provides the insight on ‘Customers also purchased this Product combinations’.

Tables Orders

amritpalsingh_0-1645464067362.png

Table Filter Product

amritpalsingh_1-1645464076776.png

Data Modelling:

amritpalsingh_2-1645464203985.png

Slicer Selection - X, Y (Filter Product)

Expected -

amritpalsingh_0-1645608711923.png

Actual -

amritpalsingh_0-1645468877468.png

 

 

Formula I used for Quantity and Price is :

Order Quantity for Customers who bought Filter Product =
CALCULATE ([Order Quantity],CALCULATETABLE (
SUMMARIZE ( Orders, Orders[Customer] ),
ALL ( Orders[Product] ),
USERELATIONSHIP ( Orders[Product], 'Filter Product'[Filter Product] )))
 
Price for Customers who bought Filter Product =
CALCULATE ([Revenue],CALCULATETABLE (
SUMMARIZE ( Orders, Orders[Customer] ),
ALL ( Orders[Product] ),
USERELATIONSHIP ( Orders[Product], 'Filter Product'[Filter Product] )))
 

I tried several logics, but nothing seems to be working. Is there anyway someone could help me with the logic?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

For future reference, the solution that worked in my case is provided below. Updated my Order Quantity and Price logics, please find teh updated logic below:

Order Quantity for Customers who bought Filter Product
=

VAR _selected=DISTINCT('Filter Product'[Filter Product])

VAR __Orders = SELECTCOLUMNS(FILTER(DISTINCT(Orders[Order No]),

CALCULATE(DISTINCTCOUNT(Orders[Product]),TREATAS( _selected, Orders[Product])) = COUNTROWS(_selected)

),"__Order",[Order No])

RETURN CALCULATE ([Order Quantity],FILTER(Orders,[Order No] IN __Orders) )

 

Price for Customers who bought Filter Product =

VAR _selected=DISTINCT('Filter Product'[Filter Product])

VAR __Orders = SELECTCOLUMNS(FILTER(DISTINCT(Orders[Order No]),

CALCULATE(DISTINCTCOUNT(Orders[Product]),TREATAS( _selected, Orders[Product])) = COUNTROWS(_selected)),"__Order",[Order No])

RETURN

CALCULATE ([Revenue],FILTER(Orders,[Order No] IN __Orders))

 

Output now getting as expected: 

amritpalsingh_0-1645608873908.png

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

For future reference, the solution that worked in my case is provided below. Updated my Order Quantity and Price logics, please find teh updated logic below:

Order Quantity for Customers who bought Filter Product
=

VAR _selected=DISTINCT('Filter Product'[Filter Product])

VAR __Orders = SELECTCOLUMNS(FILTER(DISTINCT(Orders[Order No]),

CALCULATE(DISTINCTCOUNT(Orders[Product]),TREATAS( _selected, Orders[Product])) = COUNTROWS(_selected)

),"__Order",[Order No])

RETURN CALCULATE ([Order Quantity],FILTER(Orders,[Order No] IN __Orders) )

 

Price for Customers who bought Filter Product =

VAR _selected=DISTINCT('Filter Product'[Filter Product])

VAR __Orders = SELECTCOLUMNS(FILTER(DISTINCT(Orders[Order No]),

CALCULATE(DISTINCTCOUNT(Orders[Product]),TREATAS( _selected, Orders[Product])) = COUNTROWS(_selected)),"__Order",[Order No])

RETURN

CALCULATE ([Revenue],FILTER(Orders,[Order No] IN __Orders))

 

Output now getting as expected: 

amritpalsingh_0-1645608873908.png

Hi , is there anyway to optimise this query?

 

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi  @Anonymous  - The relationship appears to be inactive, so it will not apply the filter.  Consider adding the following measure:
CALCULATE ( [Count] , USERELATIONSHIP( 'Orders'[Product] , 'Filtered Products'[Filtered Product] ))

Anonymous
Not applicable

Hi @Daryl-Lynch-Bzy,

 

I tried your measure formula, but its not working. It is only fetching selected products. my requirement is to fetch products which are bought in same order frequently with the selected products in the slicer. In my case it should be X, Y and Z with there order quantity and Total Price. please see the output screenshot from the dax : CALCULATE ( [Count] , USERELATIONSHIP( 'Orders'[Product] , 'Filtered Products'[Filtered Product] ))

 

amritpalsingh_0-1645467066369.png

 

goncalogeraldes
Super User
Super User

@Anonymous Customer A bought X, Y and also W so I guees the result you get are correct because customer bought X, Y, W and customer B bought X, Y , Z. If you want to get you need, you have to introduce a condition to your formula where the Order No needs to be the same, like:

Your measure =
CALCULATE ( SUM ( 'Orders'[Quantity] ), [Order No] = EARLIER ( [Order No] ) )

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Anonymous
Not applicable

Hi @goncalogeraldes,

 

Customer A bought X, Y and also W but in separate orders. If I am selecting X and Y, it should only give XY and Z in the outcome as they are bought in same order.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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