Help

Re: Add a different date based on a text record

1761 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Mihai_Gheorghe
4 - Data Explorer
4 - Data Explorer

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?

4 Replies 4

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.

thank you for your help, i have tried your code and it says that formula is invalid

There was a comma missing, copy the formula above and try again.

Mihai_Gheorghe
4 - Data Explorer
4 - Data Explorer

It works, thank you very much for your help!