Forum Discussion

anewsom's avatar
anewsom
Regular Visitor
4 years ago
Solved

Get child columns associated with a max value

I have a simple parent child one to many table relationship. I want to get columns associated with the most recent child.

Example:

Parent:

ID, Name

 

Child:

ID, ParentID, Date, Amount

 

I want to add a cloumn to the Parent that shows the Most recent child's amount.

  • anewsom , new column in parent table

     

    Column =

    var _max = maxx(filter(child, child[parent] = parent[ID]), Child[Date] )

    return

    maxx(filter(child, child[parent] = parent[ID] && Child[Date] = _max ), child[Amount])

     

1 Reply

  • anewsom , new column in parent table

     

    Column =

    var _max = maxx(filter(child, child[parent] = parent[ID]), Child[Date] )

    return

    maxx(filter(child, child[parent] = parent[ID] && Child[Date] = _max ), child[Amount])