Forum Discussion
Excel IF Function
- Feb 27, 2024
Thomasd842 Not sure why the AI robot used to compose the answer you marked as "best" came up with such a complicated DATE construction.
=IF(A2="yes", B2-10, B2-5) works just as good.
To answer your last question, try this:
=IF(A2="yes", B2-10, A2)
One more thing, if the "no" cell reads "no", what do I do in the formula so the output reads "no" instead of a date?
Thanks again
Thomasd842 Not sure why the AI robot used to compose the answer you marked as "best" came up with such a complicated DATE construction.
=IF(A2="yes", B2-10, B2-5) works just as good.
To answer your last question, try this:
=IF(A2="yes", B2-10, A2)
- SergeiBaklanFeb 27, 2024Diamond Contributor
I tried Gemini from Google. On any question it gives 3 variants of answer
First one
=IF(A2="yes", DATEDIF(B2, TODAY(), "D")-5, DATEDIF(B2, TODAY(), "D")-3)
Second one is more friendly but with notice
- This formula assumes that the values in cell
A2
are exactly "yes" and "no" (case-sensitive). You can adjust the formula using theLOWER
function to make it case-insensitive, like this:
=IF(LOWER(A2)="yes",B2-5,B2-3)
And third, not default variant is
=IF(A2="yes", B2-5, B2-3)
When I asked why LOWER() is needed, 3 reasons for that
1. Using
LOWER()
explicitly demonstrates your intention to perform a case-insensitive comparison.2. While Excel is currently case-insensitive, there's always a chance that future versions might offer case-sensitive options. Using
LOWER()
ensures your formulas will continue to function correctly regardless of any future changes3. Getting into the habit of using
LOWER()
for text comparisons can be beneficial, making your code more consistent and transferable across different situations.People need deep knowledge of Excel to use AI answers efficiency. Or to make the decision not to use the answer since it could be simply wrong.
- Riny_van_EekelenFeb 27, 2024Platinum Contributor
"People need deep knowledge of Excel to use AI answers"
Agreed! Though, unfortunately, most who post these AI answers here don't know what they are talking about! And they don't understand they do more harm than good.
- This formula assumes that the values in cell
- Thomasd842Feb 27, 2024Copper ContributorExcellent, thanks for simplifying