Sure, try this to start:
With({aFilter: Filter(WCOM, Stato.Value = "In deposito")}, // This is the delegable pre-filter
LookUp(
GroupBy(
Filter(
ShowColumns(
Sort(aFilter, // This is where your prefilter is included in the rest of the code
'Data/ora creazione',
SortOrder.Descending
),
"Title",
"Item"
),
EndsWith(Title, "TER") || EndsWith(Title, "P13")
),
First(GroupedTitle).Item = LblComm_2.Text
).Title
)
The idea is to get your pre-filter in the first part of the With() to be fully delegable and stored in a temporary variable (aFilter) for the purposes of performing several non-delegable operations on the result.
This will work if the pre-filter successfully reduces the row count in aFilter to be less than the maximum row limit for your app, which is 500 by default.
Does that help?
Bryan