web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to filter for a max-date in the lookup?

(1) ShareShare
ReportReport
Posted on by 30
Hello guys,
 
here's what I'm up to:
 
 
I have created a new table. There are the fields Code, Cost center, Valid from and Description.
 
In the table I have now entered three rows:
 
A001 C001 29.08.23 Test 1
A002 C001 01.09.23 Test 2
A003 C002 28.08.23 Test 3
 
 
Now I have created a new field in the sales order called Department. There the code A001 should be displayed if the document date of the order is identical to the values from the new table.
 
The sales order has the document date 29.08.23.
 
So the field should contain A001, because today is 08/29/23.
 
A003 has a different cost center and is too small by date and for A002 the date is not valid as of today.
 
I want to display the values in the orders via a lookup.
 
How can I build a date filter with MAX here?
 
I make a setrange on the new table where I filter on cost center, which must be as in the order.
 
Then two rows remain:
 
A001 C001 29.08.23 Test 1
A002 C001 01.09.23 Test 2
 
Now I make a findlast and should have only the last row.
Whose value in code I want to have in the order.
But unfortunately does not work. What am I doing wrong? Where do I have to program it and how?
 
 
Thank you.
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    98,349 Super User 2026 Season 1 on at
    Hi, I'm sorry that I didn't fully understand your needs. If you need to create a Lookup list with filtered results, you can consider using the following method.
    You can add the filter you need before RunModal method.
     
    If you just want to find the last date, you need to sort by date before findlast. You can use the following two methods to get the correct ordering.
    Record.Ascending([Boolean]) Method
     
    Hope this can give you some hints.
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,965 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,125 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 961 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans