Forum Discussion
First vs Second purchase Products
- Anonymous4 years ago
Hi jmukhtar ,
I have created a data sample,
According to this requirement: we are looking for a list of customers who have bought a specific product in first order and then use that list to see what these customers have bought in second order
Please follow these steps:
1. Create a productId table for slicer
ForSlicer = VALUES('Table'[ProducrId])2. Rank by Date
Rank = RANKX (ALL('Table'), CALCULATE ( MAX ( ( 'Table'[Date]) ) ),,ASC,Dense)3. First flag measure , and apply it to filter pane, set as "is 1"
First = IF(MAX('Table'[ProducrId]) in ALLSELECTED(ForSlicer[ProducrId]),[Rank],BLANK())4. Second flag measure, and apply it to filter pane, set as "is 1" as well
Second = var _allCustomers=SUMMARIZE(FILTER(ALL('Table'),[First]=1),[CustomerID]) return IF(MAX('Table'[CustomerID]) in _allCustomers && [Rank]=2,1,0)Outputs:
Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Here is one way to do this:
Start data:
Dax (measure):
Note that you need to use filter similar to the one in the picture to get the desired output.
I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!