Hi @Jit02,
The problem is that YEAR({FY End}) throws an error if {FY End} is empty.
The solution suggested by David doesn’t work, because monday uses the Eager approach when calculating the IF statement he suggests (if you really want to understand what this means, see A Simple Way to Handle Empty Columns and Avoid Errors in your Formulas).
So, to avoid getting errors, you need to replace all occurrences of YEAR({FY End}) by IF({FY End}=“”,“1900-01-01”,{FY End}). This is a bit ugly, but this way, the YEAR function is always provided a date and won’t fail.
Your syntax becomes:
IF(YEAR(IF({FY End}="","1900-01-01",{FY End})) < YEAR(TODAY()),
YEAR(TODAY()) - YEAR(IF({FY End}="","1900-01-01",{FY End})) + 1,
IF(YEAR(IF({FY End}="","1900-01-01",{FY End})) = YEAR(TODAY()), "1",
IF(YEAR(TODAY()) < YEAR(IF({FY End}="","1900-01-01",{FY End})), "0", "-")
)
)
There is one more problem to resolve though.
When your {FY End} is empty, you won’t get the desired “-”, but 125 right now because we are in 2024, i.e. the difference between 1900 and 2024. Next year, you’ll get 126, etc. So you need to modify the 2nd line above and test if {FY End} is empty.
Here is the final solution:
IF(YEAR(IF({FY End}="","1900-01-01",{FY End})) < YEAR(TODAY()),
IF({FY End}="","-",YEAR(TODAY()) - YEAR(IF({FY End}="","1900-01-01",{FY End})) + 1),
IF(YEAR(IF({FY End}="","1900-01-01",{FY End})) = YEAR(TODAY()), "1",
IF(YEAR(TODAY()) < YEAR(IF({FY End}="","1900-01-01",{FY End})), "0", "-")
)
)
I used 1900-01-01, but you could use any date really.
Now, if you’re serious about formulas and don’t want to deal with these issues anymore as well as get many more features, you may want to use a 3rd-party app called the Advanced Formula Booster.
Here is how you would handle this situation with the Advanced Formula Booster.
As you can see with the app, you can use as many lines as you want in your formulas, you can use comments, variables to store values that you can reuse later (anything between [ ] is a variable) and you can write to any column (it doesn’t use the formula column). In this case, I created a {Result} text column to hold the result of the formula.
Hope it helps.