Syntax Assistance - Change Value of Column Based on Value of Another

I've successfully done this before but am having trouble now.

Here's what I have. The table in question has a date field called Admittance. I also have a Status field that is currently a Ref data type that creates a toggle between two options, being In Hospital and Discharged.

What I want to create is a rule that says, "if the admittance field has data, change the Status to In Hospital"

What i tried to do to facilitate this is add the following expression into the Formula field on Admittance:

IF(
NOT(ISBLANK([_THIS])),
[Status]="Discharged",[Status]="In Hospital")


I tried the same thing but in the Status field instead. In both cases, I get a similar error. If I place it on Admittance, I get:

The expression is valid but its result type 'Yes/No' is not one of the expected types: Date

And if i place it on Status i get:
The expression is valid but its result type 'Yes/No' is not one of the expected types: Ref


So what can I do to get the desired result?

0 1 78
1 REPLY 1

Hi!  I remember your app.  glad you are making progress on it.

In your expression, you are trying to assign the value to a column.  That doesn't work in AppSheet.

Instead you have the expression result a result.  The assignment happens by nature of which column you place the expression in.  Furthermore, WHEN the assignment happens is based on which property in the column you place the expression - "Initial_Value"  or "App Formula"

In your case, because you are trying to update the value of Status, the expression must be place in the Status columns.  Reworking the example expression, you would need (by the way expression logic doesn't match your text description.  I'm following the text description):

IF( ISNOTBLANK([Admittance]), "In Hospital", "Discharged" )

Now the question is, where do you place it?

Initial_Value - Status will only be assigned automatically when the row is NEWLY created.  Users can then manually change the Status.

App Formula - Status is changed ANYTIME [Admittance] is entered/removed within the app.  Changes made to the datasource will NOT trigger the App Formula.  Users will NOT be able to manually change the [Status].

 

If you want users to be able to manually Edit the Status value AND automatically change it anytime the [Admittance] column is entered/removed/  You must do the automatic changes using an Action - either on Form Saved or as part of an automation Bot.

I hope this helps.  Please ask if you have questions.

Top Labels in this Space