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
ciken
Resolver I
Resolver I

First Order of Specific Product by Consumer ID

I have started building my consumer table with first order placed (pulling from 'Operations: Orders'), but I'd like to add a second column that shows the first time they placed an order using our Auto Refill program (Pulls from 'Operations: Orders Shopping Cart'). I've been able to use 

 
FirstTimePurchase = CALCULATE(MIN('Operations: Orders'[Order Date]), ALLEXCEPT('Operations: Orders',Customer[CustomerID])) to get the first order ever placed under that User ID, but when I try and create a new column with an additional filter 

FirstASTimePurchase = CALCULATE(MIN('Operations: Orders'[Order Date]), ALLEXCEPT('Operations: Orders',Customer[CustomerID]),FILTER('Operations: Orders Shopping Cart','Operations: Orders Shopping Cart'[Subscription Type (2)]="Auto Refill")) I end up with the first date for any auto refill order all the way down the table. I do not know what I'm doing wrong. Screen shot below...
 
Thanks

First time purchase.jpg
 
1 ACCEPTED SOLUTION
ciken
Resolver I
Resolver I

I was able to finally build the data to be accurate...below was the final solution.

 

FirstASTimePurchase = CALCULATE(MIN('Operations: Orders'[Order Date]), FILTER(ALL('Operations: Orders Shopping Cart'),'Operations: Orders Shopping Cart'[CustomerID]=EARLIER(Customer[CustomerID])&&'Operations: Orders Shopping Cart'[Subscription Type (2)]="Auto Refill"),FILTER('Operations: Orders','Operations: Orders'[Transaction State]<>"Voided"))

View solution in original post

2 REPLIES 2
ciken
Resolver I
Resolver I

I was able to finally build the data to be accurate...below was the final solution.

 

FirstASTimePurchase = CALCULATE(MIN('Operations: Orders'[Order Date]), FILTER(ALL('Operations: Orders Shopping Cart'),'Operations: Orders Shopping Cart'[CustomerID]=EARLIER(Customer[CustomerID])&&'Operations: Orders Shopping Cart'[Subscription Type (2)]="Auto Refill"),FILTER('Operations: Orders','Operations: Orders'[Transaction State]<>"Voided"))
v-shex-msft
Community Support
Community Support

HI @ciken,

Power bi data model tables do not support setting multiple sort order field.

For your requirement, I'd like to suggest you create a calculated column with ISONORAFTER function to rank based on multiple columns and sort by this new field or do these sorting in query editor side and add an index column to save current sorting effect.

Sorting by multiple columns 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.