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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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