2

How to combine two dynamic array formula (like filter functions) one below another?

=FILTER(A5:B14,A5:A14>5)
=FILTER(Sheet2!A5:B14,Sheet2!A5:A14>8)

I want the results to come one below another irrespective of number of rows picked up. Is it possible ?

JvdV
  • 70,606
  • 8
  • 39
  • 70
The King
  • 4,600
  • 3
  • 39
  • 58
  • 2
    [Might be useful](https://exceljet.net/formula/lambda-append-range). Combining (appending) ranges isn't very straightforward unfortunately. – BigBen Apr 05 '21 at 13:31

4 Answers4

1

This isn't very easy too achieve unfortunately. I guess one could try use LAMBDA() but it can also be achieved using FILTERXML() and TEXTJOIN() when these FILTER() is applied as per your example:

enter image description here

Formula in G5:

=LET(X,FILTERXML("<t><s>"&TEXTJOIN("</s><s>",,FILTER(A5:B14,B5:B14>5,""),FILTER(D5:E14,E5:E14>5,""))&"</s></t>","//s"),INDEX(X,SEQUENCE(COUNTA(X)/2,2)))

I used LET() but I guess you could also add two COUNTIFS() instead.

JvdV
  • 70,606
  • 8
  • 39
  • 70
  • Super... Works Great... However my version of Excel still does not support LET(). But I just adjusted the countifs... Thanks – The King Apr 05 '21 at 15:59
0

Using the solution proposed in this answer, you join miltiple ranges or dynamic array formulas with this formula, replacing YOUR_RANGES with the ranges or formulas you wish to join:

=FILTERXML("<A><B>" & TEXTJOIN("</B><B>",TRUE,YOUR_RANGES) & "</B></A>", "//B")

In your case, you can split the filter to get only column A in the first result column, and only column B for the second result column:

RESULT SHEET A1 CELL:

=FILTERXML("<A><B>" & TEXTJOIN("</B><B>",TRUE, FILTER(A5:A14,$A5:$A14>5); FILTER(Sheet2!A5:A14,Sheet2!$A5:$A14>8) ) & "</B></A>", "//B")

RESULT SHEET B1 CELL:

=FILTERXML("<A><B>" & TEXTJOIN("</B><B>",TRUE, FILTER(B5:B14,$A5:$A14>5); FILTER(Sheet2!B5:B14,Sheet2!$A5:$A14>8) ) & "</B></A>", "//B")

This will join the 2 filters, one beneath the other, although each column will have a separate dynamic array.

cyberponk
  • 1,585
  • 18
  • 19
0

Found an excellent answer (it was also provided as a comment to the question, but I believe it merits being a full answer) in the form of a lambda UDF by Dave Burns at ExcelJet: https://exceljet.net/formula/lambda-append-range

=LAMBDA(range1,range2,default,
  LET(
  rows1,ROWS(range1),
  rows2,ROWS(range2),
  cols1,COLUMNS(range1),
  cols2,COLUMNS(range2),
  rowindex,SEQUENCE(rows1+rows2),
  colindex,SEQUENCE(1,MAX(cols1,cols2)),
  result,
  IF(
    rowindex<=rows1,
    INDEX(range1,rowindex,colindex),
    INDEX(range2,rowindex-rows1,colindex)
  ),
  IFERROR(result,default)
  )
)
ttarchala
  • 4,277
  • 2
  • 26
  • 36
0

Recently Office365 introduced two functions HSTACK and VSTACK. We can use VSTACK function for this requirement.

 =VSTACK(FILTER(A5:B14,A5:A14>5),FILTER(Sheet2!A5:B14,Sheet2!A5:A14>8))
The King
  • 4,600
  • 3
  • 39
  • 58