Apr 22, 2021 04:38 AM
Hello, I have a text field and a date field. I am trying to write a code that finds a certain value inside the text field and adds a number of days based on that value. So far I have managed to write this:
IF(
FIND(‘3 luni’,{Produs}),DATEADD({Data activării},90,‘days’),FIND(‘6’,{Produs}),DATEADD({Data activării},180,‘days’),FIND(‘12’,{Produs}), DATEADD({Data activării},365,‘days’))
It works for the first value (“3 luni”), but it returns “1” for anything else. Can you help me?
Apr 22, 2021 09:45 AM
You have too many arguments within a single IF()
statement. IF()
s should only have no more than three arguments, if you need more than three you need a nested IF()
statement:
DATEADD(
{Data activării},
IF(
FIND('3 luni',{Produs}),
90,
IF(
FIND('6',{Produs}),
180,
IF(
FIND('12',{Produs}),
365,
0
)
)
),
'days'
)
Since in your example you’re always adding days to the same field, I simplified things a bit to only call DATEADD()
once, and placed the nested IF()
conditional within it.
Apr 22, 2021 11:24 AM
thank you for your help, i have tried your code and it says that formula is invalid
Apr 22, 2021 11:53 AM
There was a comma missing, copy the formula above and try again.
Apr 23, 2021 01:48 AM
It works, thank you very much for your help!