Search code examples
datedatetimeif-statementgoogle-sheetsstring-formatting

Why does making this Google Sheets formula an ARRAYFORMULA change it's behavior?


This formula works on a per-row basis:

=(IF(today()-D2 > 365,text(D2:D,"mmm yyyy"),text(D2:D,"mmm d")))

But if I make it an ARRAYFORMUAL like below it always returns text(D2:D,"mmm yyyy") even when today()-D2 > 365 is False.

=arrayformula(IF(LEN(D2:D) = 0, "", (IF(today()-D2 > 365,text(D2:D,"mmm yyyy"),text(D2:D,"mmm d")))))

See screenshot below. Column D is the source date. Column F is the ARRAYFORMULA. Column G is the standard formula (hard-coded per row vs ARRAYFORMULA).

I want the ARRAYFORMUAL in column F to replicate the result in column G.

enter image description here


Solution

  • try:

    =ARRAYFORMULA(IF(LEN(D2:D), IF((TODAY()-D2:D)>365,
     TEXT(D2:D, "mmm yyyy"), TEXT(D2:D, "mmm d")), ))
    

    enter image description here