cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors