Greetings, all! Really hope someone can help with this as I've been going round in circles.
I need to create a collection that filters a collection to show specific records but also shows the longest text value for items with the same ID in the original collection. It's probably easier with an example.
Here's the collection I'm starting with named Data:
| Item | flagField | Position | Length |
| Category | 1 | 1 | 8 |
| ABC | 0 | 1 | 3 |
| DEF Corporation | 0 | 1 | 15 |
| Subcategory | 1 | 2 | 11 |
| HI | 0 | 2 | 2 |
Here's the new collection I want to create called TableFields:
| Field | Position | MaxLengthText |
| Category | 1 | DEF Corporation |
| Subcategory | 2 | Subcategory |
I currently get close to this by doing the following:
ClearCollect(
TableHeaders,
Filter(
Data,
flagField = 1
));
I thought I could get the record with the greatest length this way but without success:
ClearCollect(
TableFields,
AddColumns(Filter(
Data,
flagField= 1
),"MaxLengthRecord",FirstN(Sort(Filter(Data, flagField>0 && Position=Position),"Length",Descending),1)
));
Anyone have any ideas?