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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
amontenegro93
Regular Visitor

latest date in a new column

hi,
first sorry for my rough english

i have a dim table with clients, like this:

idnamelast name
1jondoe
2janedeo


in my fact table i have purchase by those clients:

Client_iddateitem
124/12/2022a1
225/12/2022a2
126/12/2022a3
227/12/2022a4

 

what i need is a new column in the dim table with the least purchase date for each client, for example:

idnamelast nameleast purchase date
1jondoe26/12/2022
2janedeo27/12/2022

 

i cant find the correct functions to do this so i really apriciate your help, thanks!

1 ACCEPTED SOLUTION
adudani
Super User
Super User

Hi @amontenegro93 ,

 

For the last/ latest purchase date for each customer:

Create a measure using the following DAX:

last transaction date =
MAXX(
FILTER(
FactTable,
FactTable[Customer_ID]=FactTable[Customer_ID]
),
FactTable[DateColumn]
)

For the first purchase made by the customer, replace MAXX with MINX. ( Not sure which one is required).
With the relationship from the date table to the fact table, you can filter this measure with any customer id context.
 
If this does not meet your requirement: Check out this link. Firstdate/lastdate might be applicable.
(114) How To Calculate Days Since Last Purchase Using DAX In Power BI [2022 Update] - YouTube 

Please accept this solution if it solves your query.
Appreciate a thumbs up if it helped.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

To your Table visual, drag the fields from the client Table.  Write this measure and format it as a Date

Last date = max(Fact[Date])

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
adudani
Super User
Super User

Hi @amontenegro93 ,

 

For the last/ latest purchase date for each customer:

Create a measure using the following DAX:

last transaction date =
MAXX(
FILTER(
FactTable,
FactTable[Customer_ID]=FactTable[Customer_ID]
),
FactTable[DateColumn]
)

For the first purchase made by the customer, replace MAXX with MINX. ( Not sure which one is required).
With the relationship from the date table to the fact table, you can filter this measure with any customer id context.
 
If this does not meet your requirement: Check out this link. Firstdate/lastdate might be applicable.
(114) How To Calculate Days Since Last Purchase Using DAX In Power BI [2022 Update] - YouTube 

Please accept this solution if it solves your query.
Appreciate a thumbs up if it helped.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a Kudos 🙂
Kind Regards,
Avinash

it works, thank you!

Helpful resources

Announcements
ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.