cancel
Showing results for
Did you mean:
Frequent Visitor

## 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

Result

Thank you!

Mike

1 ACCEPTED SOLUTION

Accepted Solutions
Super User I

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/hi...

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

Proud to be a Super User!

3 REPLIES 3
Super User I

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/hi...

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

Proud to be a Super User!

Super User IV

@SurferMike , 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://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-Y...

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Community Support

Hi @SurferMike ,

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])))``

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.

Announcements

#### Power Platform Community Conference

Check out the on demand sessions that are available now!

#### Power Platform October Community Highlights

Check out the top community contributors across all of the communities

#### Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors