IMPORTRANGE() vs literal range reference, single cell formula

Viewed 15

I am trying to build a single-cell formula to transform some data that comes from another sheets document. However, the formula only seems to work when the IMPORTRANGE() is done separately, in order to then reference the range where the IMPORTRANGE() has rendered its output.

See the image below:

Formula error ('Array arguments to COUNTIFS are of different size.') when passing the IMPORTRANGE() formula instead of a cell range reference.

The first row spills the data from a simple IMPORTRANGE(). The third row transforms the data referencing the first row as a range. The second row contains the exact same formula and transformations as the third row, but with IMPORTRANGE inside of the formula, instead of referencing the range.

Why does this happen? Is there hope for me in my quest to have it all inside a single cell?

The full formula is as follows.

=ArrayFormula(
    if(
        COUNTIF(
            IMPORTRANGE(
                "example",
                "Form responses 2!A1:CE1"
            ),
            IMPORTRANGE(
                "example",
                "Form responses 2!A1:CE1"
            )
        ) > 1,
        CONCAT(
            IMPORTRANGE(
                "example",
                "Form responses 2!A1:CE1"
            ),
            ArrayFormula(
                COUNTIFS(
                    IMPORTRANGE(
                        "example",
                        "Form responses 2!A1:CE1"
                    ),
                    IMPORTRANGE(
                        "example",
                        "Form responses 2!A1:CE1"
                    ),
                    COLUMN(
                        IMPORTRANGE(
                            "example",
                            "Form responses 2!A1:CE1"
                        )
                    ),
                    "<=" & COLUMN(
                        IMPORTRANGE(
                            "example",
                            "Form responses 2!A1:CE1"
                        )
                    )
                )
            )
        ),
        IMPORTRANGE(
            "example",
            "Form responses 2!A1:CE1"
        )
    )
)
1 Answers

try:

=ARRAYFORMULA(IMPORTRANGE("1sPf96eJpnREppTw4znKGpn8BfAt6qDh4iVNBQK35Uyc","Sheet1!A1:Z1")&COUNTIFS(
IMPORTRANGE("1sPf96eJpnREppTw4znKGpn8BfAt6qDh4iVNBQK35Uyc","Sheet1!A1:Z1"),
IMPORTRANGE("1sPf96eJpnREppTw4znKGpn8BfAt6qDh4iVNBQK35Uyc","Sheet1!A1:Z1"),       SEQUENCE(1, COLUMNS(
IMPORTRANGE("1sPf96eJpnREppTw4znKGpn8BfAt6qDh4iVNBQK35Uyc","Sheet1!A1:Z1"))),"<="&SEQUENCE(1, COLUMNS(
IMPORTRANGE("1sPf96eJpnREppTw4znKGpn8BfAt6qDh4iVNBQK35Uyc","Sheet1!A1:Z1")))))

enter image description here

Related