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
EvertonRamone
Helper I
Helper I

DAX - Customer first purchase

I need a measure wich returns me the first purchase of customers who bought product B (key product 2)

 

This is my data model

 

FactSales   
KeyDateKeyCustomerKeyProductTotal
11112,9
12213
131156,4
141564,8
211894,8
22156,5
312564,85
323564,8
4111325,6
421132,3

 

Customer
KeyCustomerName
1Jean
2Mari
3Lisa
4Julian
5Jhonny

 

Calendar
KeyDateDate
101/01/2018
202/01/2018
301/05/2018
401/08/2018

 

Product
KeyProductProduct
1A
2B
3C
1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi EvertonRamone,

 

Create a measure using DAX as below:

Result = 
VAR KeyDate = CALCULATE(MIN('Calendar'[KeyDate]), FILTER('Calendar', 'Calendar'[Date] = MIN('Calendar'[Date])))
VAR KeyProduct = CALCULATE(MIN('Product'[KeyProduct]), FILTER('Product', 'Product'[Product] = "B"))
RETURN
CALCULATE(MIN('Customer'[Name]), FILTER('FactSales', 'FactSales'[KeyDate]  = KeyDate && FactSales[KeyProduct] = KeyProduct))

Capture.PNG 

 

Regards,

Jimmy Tao

View solution in original post

2 REPLIES 2
EvertonRamone
Helper I
Helper I

@v-yuta-msft, Maybe I expressed myself wrong.

 

I meant I need to now every date of first purchase by customer

 

Customer A - 20/01/2018

Customer B - 14/01/2018

Customer C- 22/01/2018

v-yuta-msft
Community Support
Community Support

Hi EvertonRamone,

 

Create a measure using DAX as below:

Result = 
VAR KeyDate = CALCULATE(MIN('Calendar'[KeyDate]), FILTER('Calendar', 'Calendar'[Date] = MIN('Calendar'[Date])))
VAR KeyProduct = CALCULATE(MIN('Product'[KeyProduct]), FILTER('Product', 'Product'[Product] = "B"))
RETURN
CALCULATE(MIN('Customer'[Name]), FILTER('FactSales', 'FactSales'[KeyDate]  = KeyDate && FactSales[KeyProduct] = KeyProduct))

Capture.PNG 

 

Regards,

Jimmy Tao

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.