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
av9
Helper III
Helper III

Calculate customers first purchase date by product

New to Dax and I am trying to work out the first purchase date for each product, I have three tables: 

 

Customer
Customer A
Customer B
Customer C

 

Product
Product A
Product B
Product C

 

Calendar
June-20
May-20
Apr-20

 

Ideally, I'd like to see the data presented something like this:

CustomerProductDate
Customer AProduct AApr-20
Customer AProduct BApr-20
Customer AProduct CMay-20
1 ACCEPTED SOLUTION
harshnathani
Community Champion
Community Champion

HI @av9 ,

 

Suppose this is your Order Table.

 

1.jpg

 

 

You can use the following measure

 

Measure =

MINX(
TOPN (1,'Table',MIN('Table'[Date]),ASC),'Table'[Date]
)

 

2.JPG

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

View solution in original post

6 REPLIES 6
HotChilli
Super User
Super User

Is there an 'Orders' table?

If not, you'll have to provide more details about the tables you have and any relationships.

Yes there is an orders table that contains the daily data , i.e. 

 

CustomerDateProduct
Customer A30/04/2020Product A

Ok, good, what have you tried so far?

Tried using MIN to get the first date a purchase appears for a Customer :

 
First Purchase Date = CALCULATE ( MIN ( 'Order'[Date]), ALLEXCEPT ( Order, 'Order'[Date] ))
 
In a Table when I add the Product First Purchase date is repeated the same for every product. Not sure how to inlcude a product in dax formula.
harshnathani
Community Champion
Community Champion

HI @av9 ,

 

Suppose this is your Order Table.

 

1.jpg

 

 

You can use the following measure

 

Measure =

MINX(
TOPN (1,'Table',MIN('Table'[Date]),ASC),'Table'[Date]
)

 

2.JPG

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

Can't we simplify the measure ? the visualisation will provide the context.  

If we want powerbi to do the work,  let's try dragging the date on to the visual and , in the Values well, click the dropdown on date and choose the appropriate aggregation (not Do Not Summarize)

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.