I have a text label in a budget form, I used to create my document title. This title is like : "BU[YEAR]-001".
When my users save the document, I want to take the year, find the highest existed document, add one, and save.
Exemple : my datasources contains BU2018-001, BU2019-001 and BU2019-002. If my user select 2019 in year label, and save the document, I want the title to be BU2019-003. If it's 2018 => BU2018-002 and if the year not exist, like 2020 => BU2020-001.
Using : LookUp(Budget2.Title;Text(Annee) in Title;Title), I can restrain to my budget with the year in it, but it only take the first one.
Can you help me with this, please?
Thanks !
As you found out, LookUp only returns one item, in no specific order (likely the first one that was entered, but this is not guaranteed). If you want a specific record (the last one), you can first sort the source in descending order, then take the first element from the sorted result:
First(
SortByColumns(
Filter(
Budget2;
Text(Annee) in Title);
"Title";
Descending)).Title