Conditional Logic in Forms
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
-
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
-
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...
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 497 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives