0

I have two tables linked with one to N relation

Main Table value : A

Relation Table : multiple values for value A that sometimes are identical to one another

I want to use relation_aggregate to concatenate the values of the relation table only if they are different to avoid having a result like this value 1, value 2, value 2, value 2, value 3, value 3, value 45, value 47.

I would need to have value 1, value 2, value 3, value 45, value 47 as results.

for now i have this :

relation_aggregate( 
    'chrono_cer_field_3_S2_Structu_UE',
    'concatenate',
    "field_6",
    concatenator:=';'
)
1
  • 1
    Please Edit your Question to contain a question.
    – Vince
    Apr 8, 2022 at 12:02

1 Answer 1

1

I can't test fully because I don't have any relational tables to hand, but something like this should work:

array_to_string(                                    -- convert array to string using the ';' delimiter
    array_distinct(                                 -- get distinct values from array
        relation_aggregate(
            'chrono_cer_field_3_S2_Structu_UE',
            'array_agg',                            -- get an array of values
            "field_6"
        )
    ),
    delimiter:=';'
)
7
  • In fact,, my relation table is not in array format so i'm not sure this would work.
    – tonyduky
    Apr 8, 2022 at 12:41
  • 1
    That is what the array_agg aggregate is for, it creates an array of values.
    – Matt
    Apr 8, 2022 at 12:45
  • .Also the values in the relation table are text.
    – tonyduky
    Apr 8, 2022 at 12:49
  • Have you tried the expression to see if it does what you want?
    – Matt
    Apr 8, 2022 at 12:52
  • array_distinct syntax error : wrong number of arguments expected 1 but received 2
    – tonyduky
    Apr 8, 2022 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.