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
Anonymous
Not applicable

Query - Find max date for each customer, if null take last previous transaction date, by month year

Hi,

 

I have a table with transaction dates for each customer.

Then I have date table with dates, months, years.

 

I want to have a new table that will show for each customer his last transaction date per month/year.

If transaction date is missing in one month&year then take previous transaction date.

 

Example

SurferMike_0-1597158549312.png

Result

SurferMike_1-1597158842734.png

Thank you!

Mike

1 ACCEPTED SOLUTION
Daviejoe
Memorable Member
Memorable Member

Hi @Anonymous 

 

I've had a similar situation, the below helped me solve it.  I think the blank date would get resolved by this also.

 

https://community.powerbi.com/t5/Desktop/Consuming-only-updated-records-in-Power-query/m-p/726938/highlight/false#M350797





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @Anonymous ,

 

Check the measure below.

Measure = CALCULATE(MAX('Table'[date]),FILTER(ALLEXCEPT('Table','Table'[customer]),MONTH('Table'[date])<=SELECTEDVALUE('CALENDAR'[month])&&YEAR('Table'[date])=SELECTEDVALUE('CALENDAR'[year])))

1.PNG 

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@Anonymous , Try with a date table. Month year should be there in month year table

 

Max till year

YTD = CALCULATE(MAX(Table[Transaction Date]),DATESYTD('Date'[Date],"12/31"))

 

max across year


Cumm = CALCULATE(MAX(Table[Transaction Date]),filter(date,date[date] <=maxx(date,date[date])))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184


Appreciate your Kudos.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Daviejoe
Memorable Member
Memorable Member

Hi @Anonymous 

 

I've had a similar situation, the below helped me solve it.  I think the blank date would get resolved by this also.

 

https://community.powerbi.com/t5/Desktop/Consuming-only-updated-records-in-Power-query/m-p/726938/highlight/false#M350797





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.