Forum Discussion

drstrong's avatar
drstrong
Frequent Visitor
2 years ago
Solved

Create collection grouping by Lookup column

My overall objective is to create a collection from my Notes table that returns the corresponding note detail value for the max created record for that given lookup value.

 

note table structure 

ID  LookUpValue  Note Detail  Created On

1    1111               note 1.          3/1/24

2    1111               Note 2.          3/9/24

3    2222                Note 3.          3/4/24

4    3333               Note 4.          3/3/24

5   2222               Note 5.           3/5/24

 

expected results

LookupValue.  Note Detail.   Created on

1111.                Note 2.         3/9/24

2222.                Note 5.         3/5/24

3333.                Note 4.       3/3/24

 

 

I have tried group by but it will not let me group the lookup column. I get error that it's invalid.

ClearCollect(temp,GroupBy(NoteTable, LookupValue,"group"))

 

i have tried the below but it only provides the overall max record for the entire table and not by lookup value.

 

ClearCollect(MaxExeStatus,

    ForAll(

        Distinct(NoteTable,LookUpValue.LookUpID),

        {

        LookUpValue: ThisRecord.Value,

        MaxRecord: Last(FirstN(Sort(Filter(NoteTable, LookUpValue.LookUpID = LookUpValue.LookUpID), 'Created On', SortOrder.Descending),1))}

    ));

3 Replies