Conditional Logic in Forms

Options

I am trying to use logic in my form, for example I know that I can do

'if field fruit is apple then show field grocery'

however I was wondering if there was a way to do

"If fruit is any of apple or orange AND dessert is cookie THEN show the following fields: grocery"

, so that two different fields (columns) could be used in the if part of the condition.

Best Answer

  • Toufong Vang
    Toufong Vang ✭✭✭✭✭
    Answer ✓
    Options

    If "Fruit" is the column name, then you can search for the value Fruit@row in the text string of known fruits, "apple banana kiwi orange". Finding that the value of Fruit@row is in the text string--that is to say--the search returns something other than zero, AND finding that a search for Dessert@row in "cake cookie jello pie" returns something other than zero, the formula returns "Grocery". It otherwise returns "Not Grocery."

    The expression to search for fruit looks like this... FIND( Fruit@row, "apple banana kiwi orange")

    The expression to search for dessert looks like this... FIND( Dessert@row, "cake cookie jello pie")

    You require BOTH to be true so use the function AND(), that is...

    AND( FIND(Fruit@row, "apple banana kiwi orange") <> 0 , FIND(Dessert@row, "cake cookie jello pie") <> 0 )

    The general structure of the formula looks like this...

    IF( AND( FIND(fruit) <> 0 , FIND(dessert) <> 0 ), "Grocery", "Not Grocery" )

    Plug in the details and your formula ends up as...

    IF( AND( FIND(Fruit@row, "apple banana kiwi orange") <> 0, FIND(Dessert@row, "cake cookie jello pie") <> 0 ), "Grocery", "Not Grocery" )

    There are other approaches as well...

Answers

  • Toufong Vang
    Toufong Vang ✭✭✭✭✭
    Answer ✓
    Options

    If "Fruit" is the column name, then you can search for the value Fruit@row in the text string of known fruits, "apple banana kiwi orange". Finding that the value of Fruit@row is in the text string--that is to say--the search returns something other than zero, AND finding that a search for Dessert@row in "cake cookie jello pie" returns something other than zero, the formula returns "Grocery". It otherwise returns "Not Grocery."

    The expression to search for fruit looks like this... FIND( Fruit@row, "apple banana kiwi orange")

    The expression to search for dessert looks like this... FIND( Dessert@row, "cake cookie jello pie")

    You require BOTH to be true so use the function AND(), that is...

    AND( FIND(Fruit@row, "apple banana kiwi orange") <> 0 , FIND(Dessert@row, "cake cookie jello pie") <> 0 )

    The general structure of the formula looks like this...

    IF( AND( FIND(fruit) <> 0 , FIND(dessert) <> 0 ), "Grocery", "Not Grocery" )

    Plug in the details and your formula ends up as...

    IF( AND( FIND(Fruit@row, "apple banana kiwi orange") <> 0, FIND(Dessert@row, "cake cookie jello pie") <> 0 ), "Grocery", "Not Grocery" )

    There are other approaches as well...