I have a spreadsheet formula in which I use exactly the same FILTER function twice inside an INDEX function. Is there any way to avoid repeating myself, and/or a simpler version of the expression?
The expression looks like this (separated into multiple lines for a tiny bit of extra clarity):
=INDEX(
FILTER($A$1:$P$1, ($A$1:$P$1 = "ANIM")+($A$1:$P$1 = "COMP")+($A$1:$P$1 = "SENT TO EDIT"),
NOT (ISBLANK(A2:P2))),
COLUMNS(
FILTER($A$1:$P$1, ($A$1:$P$1 = "ANIM")+($A$1:$P$1 = "COMP")+($A$1:$P$1 = "SENT TO EDIT"),
NOT (ISBLANK(A2:P2)))))`
What the expression does is return the heading of the rightmost non-blank column in the row, so long as the column is one of ANIM
, COMP
, or SENT TO EDIT
.
See the formula in action in column Q of this Google Sheets.
Since the FILTER function is exactly the same both times, if I could use a variable, it could be re-written something like this:
range1 = FILTER(.....); INDEX(range1, COLUMNS(range1));
Is there any way to do something like that - or an equivalent - in order to avoid repeating my FILTER expression?