Skip to main content
May 31, 2023
Solved

Multiple if function with one value

  • May 31, 2023
  • 9 replies
  • 0 views

Hello, I have a multiple if condition that returns a list, but what I need is for it to return the condition that is only true. Thankss!!!

if(
  {and(
      ri!tipo = "Alzada",
    a!isNotNullOrEmpty(ri!feRegistro),
  ),
  and(
    ri!tipo = "Reposición",
    a!isNotNullOrEmpty(ri!feRegistro),
  ),
  and(
    ri!tipo = "Revisión",
    a!isNotNullOrEmpty(ri!feRegistroAdmin),
  ),
  },
  {ri!feRegistro + 90, ri!feRegistro + 30, ri!feRegistroAdmin + 30},
  {ri!feRegistro, ri!feRegistro, ri!feRegistroAdmin}
)

    Best answer by davel001150

    If all 3 need to be true, then use and().  Then return whatever single value you want to return when all 3 are true.  Then whatever single value you want when they're not all 3 true.

    If any of the 3 need to be true, use or().  Then whatever single value when any are true.  Then whatever single value you want when all 3 are false.

    If it's something else more complex than that, you might want to consider a!match().  Then you can specifically define each combination of your 3 inputs, and what it should return for each combination.

    9 replies

    harshitb6843
    May 31, 2023

    You have mixed up a lot of things here. Can you help me understand what are you trying to achieve? Try giving the sample input and desired output based on that input. That should help.

    May 31, 2023

    What I am trying here is that if it is of a type ("Alzada", "Reposición", "Revision"), the date that is completed in a field adds 90 or 30 days at the date selected

    May 31, 2023

    the date is rule input  ri!feRegistro, ri!feRegistroAdmin is a date, and tipo is a text

    stefanhelzle0001
    Brainy
    May 31, 2023

    Using an if() with more than 3 parameters is not supported. This seems to be a more complex logic with more than a single output. We need more details.

    May 31, 2023

    What I need is that it only returns the true condition instead of the list with the 3 conditions

    harshitb6843
    May 31, 2023

    You are getting 3 because the first parameter of your if() statement has 3 parameters. You need to wrap them in a function that returns only a single parameter. Like I have done above. 

    davel001150
    May 31, 2023

    If all 3 need to be true, then use and().  Then return whatever single value you want to return when all 3 are true.  Then whatever single value you want when they're not all 3 true.

    If any of the 3 need to be true, use or().  Then whatever single value when any are true.  Then whatever single value you want when all 3 are false.

    If it's something else more complex than that, you might want to consider a!match().  Then you can specifically define each combination of your 3 inputs, and what it should return for each combination.

    saifalik8679
    Known Participant
    May 31, 2023

    Agree