Formula to capture as text, all the rows of another table that reference the current row

Basically, two tables… Action Plans (Planos de Ação) and SubActions (SubAções)

For easier viewing (since Action Plans will be viewed as one of 5 widgets in anotherpage) I don´t want to have yet another widget showing the SubActions of an Action Plan.

So I decided to try to capture the description of each SubAction that references the main Action Plan.

This is the code… that is not working lol. No error message, but also, no text.

def get_subactions(plan_id):
    subactions = []
    for subacao in SubAcoes:
        if subacao['PAsFK'] == plan_id:
    return subactions

Planos_de_Acoes = [{'id': 1, 'other_field': 'value1'}, {'id': 2, 'other_field': 'value2'}]
SubAcoes = [{'PAsFK': 1, 'Descricao': 'subacao1'}, {'PAsFK': 2, 'Descricao': 'subacao2'}]

for plano in Planos_de_Acoes:
    subactions = get_subactions(plano['id'])
    subactions_string = "\n".join(subactions)
    plano['SubAcoes'] = subactions_string

Whenever possible, you should avoid looping in Python, in favor of Grist’s lookup functions.

Without any sample document, I’m making the following assumptions: the formula you show is a SubAções column of Planos de Ação; PAsFK is the name of the SubAções table column referring to Plano de Ação. This should do the trick: