0

-- This works but gives me LATEST_STATE of 45 on all rows AddColumns(Sort(TABLE_A,UPDATED_ON,Descending),"MyDemoColumn",First(Sort(Filter(TABLE_B,PRIMARY_ID = 45),UPDATED_ON,Descending)).LATEST_STATE)

-- This does not AddColumns(Sort(TABLE_A,UPDATED_ON,Descending),"MyDemoColumn",First(Sort(Filter(TABLE_B,PRIMARY_ID = TABLE_A[@PRIMARY_ID]),UPDATED_ON,Descending)).LATEST_STATE)

where TABLE_B has a foreign key reference to table a (Many to One)

Is my syntax incorrect while using the @

Updated 8/25 I also tried the following. It works but gives me wrong values AddColumns(Sort(TABLE_A,UPDATED_ON,Descending),"MyDemoColumn",First(Sort(Filter(TABLE_B,PRIMARY_ID = ThisRecord.PRIMARY_ID),UPDATED_ON,Descending)).LATEST_STATE)

J D
  • 707
  • 7
  • 13

1 Answers1

0

You can use the As command to disambiguate the two PRIMARY_ID fields:

AddColumns(
    Sort(TABLE_A, UPDATED_ON, Descending) As TA,
    "MyDemoColumn",
    First(
        Sort(
            Filter(TABLE_B, PRIMARY_ID = TA.PRIMARY_ID),
            UPDATED_ON,
            Descending
        )
    ).LATEST_STATE
)
carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
  • Thanks Carlos, checking it out now – J D Aug 25 '21 at 16:14
  • AddColumns(Sort(TABLE A,UPDATED_ON,Descending),"MyDemoColumn","Test") -- Works AddColumns(Sort(TABLE A,UPDATED_ON,Descending) AS TA,"MyDemoColumn","Test") -- Does not work – J D Aug 25 '21 at 16:20