IMTheNachoMan
IMTheNachoMan

Reputation: 5811

concat rows after doing multiple table joins in a Google Sheet

I have created a minimal example sheet at https://docs.google.com/spreadsheets/d/1nrPMDTKD0uHbWkAu-3c9DUoxBptB13lScOe8XI8zxF4/edit?usp=sharing.

I will explain:

Now, in issues and recommendations.plans (column C) I want an ARRAYFORMULA or something that will find all of the recommendation plans.plans (column C) for the recommendations in issues and recommendations.recommendation (column B), and combine them into one cell.

In the last column of issues and recommendations I put an example column with the expected output. Using issue 1 as an example:

Upvotes: 1

Views: 85

Answers (1)

player0
player0

Reputation: 1

all you need to do is:

=ARRAYFORMULA(SUBSTITUTE(SUBSTITUTE(REGEXREPLACE(TRIM(FLATTEN(QUERY(
 TRANSPOSE(IFERROR(VLOOKUP(SPLIT(B2:B, CHAR(10)), 
 TRIM(SPLIT(FLATTEN(TRIM(QUERY(QUERY({"- "&'recommendation plans'!B2:B&"♦", 
 "- "&'recommendation plans'!C2:C&"♥♥", ROW('recommendation plans'!A2:A)}, 
 "select max(Col2) where Col1 <> '- ♦' group by Col3 pivot Col1"),,9^9))), 
 "♦")), 2, 0))),,9^9))), "♥♥$", ), "♥ -", "♥-"), "♥", CHAR(10)))

enter image description here


=ARRAYFORMULA(
    SUBSTITUTE(
        SUBSTITUTE(
            REGEXREPLACE(
                TRIM(
                    FLATTEN(
                        QUERY(
                            TRANSPOSE(
                                IFERROR(
                                    VLOOKUP(
                                        SPLIT(
                                            B2:B,
                                            CHAR(10)
                                        ),
                                        TRIM(
                                            SPLIT(
                                                FLATTEN(
                                                    TRIM(
                                                        QUERY(
                                                            QUERY(
                                                                {
                                                                    "- " & 'recommendation plans'!B2:B & "♦",
                                                                    "- " & 'recommendation plans'!C2:C & "♥♥",
                                                                    ROW('recommendation plans'!A2:A)
                                                                },
                                                                "select max(Col2) where Col1 <> '- ♦' group by Col3 pivot Col1"
                                                            ),
                                                            ,
                                                            9^9
                                                        )
                                                    )
                                                ),
                                                "♦"
                                            )
                                        ),
                                        2,
                                        0
                                    )
                                )
                            ),
                            ,
                            9^9
                        )
                    )
                ),
                "♥♥$",
            ),
            "♥ -",
            "♥-"
        ),
        "♥",
        CHAR(10)
    )
)

Upvotes: 1

Related Questions