Is it possible to preselect an option in an EnumList type column out of the available options when a form is opened up for the first time?

Hi,

In my app, in a table called “Delivery Outcomes”, there’s an EnumList type column called [Maternal Outcomes] that has the following values in them.

  1. Postpartum haemorrhage
  2. Intensive care admission
  3. Cardiac failure
  4. Pulmonary oedema
  5. Intubation

Let’s say in a different table (table name: “Admission for Delivery”), the user records that the patient had pulmonary oedema by recording a ‘Y’ on a Y/N type [Pulmonary Oedema] column.

Now when the user comes to create an entry on the “Delivery Outcomes” table, I want the [Maternal Outcomes] EnumList column to have its ‘Pulmonary oedema’ preselected. Is this doable?

The following expression I tried just showed the word 'Pulmonary Oedema" in the [Maternal Outcomes] EnumList column removing other values from it.

IF((CONTAINS(SELECT(Admission for Delivery[Pulmonary oedema], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Pulmonary oedema”,"")

If anyone can help me to figure out a way to do that, I’d really appreciate it!

Thanks.

Solved Solved
0 9 587
1 ACCEPTED SOLUTION

Where is this expression? I’m assuming you’ve mistakenly put it into valid_if? Try it in Initial Value.

View solution in original post

9 REPLIES 9

Where is this expression? I’m assuming you’ve mistakenly put it into valid_if? Try it in Initial Value.

Hi @Marc_Dillon, thank you so much! It worked! I had mistakenly put it in ‘App formula’. Thanks again!

Hi @Marc_Dillon, If I wanted multiple values to be highlighted like that, can I use the IFS expression in Initial value? I tried, but it didn’t work.

IFS((CONTAINS(SELECT(Admission for Delivery[Pulmonary oedema], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Pulmonary oedema”,

(CONTAINS(SELECT(Delivery Outcomes[ICU admission], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Intensive care admission”)

Thanks again for your input.

That’s not quite how IFS() works.

Let’s first take a look at your expression and try to build a better way to do that.

It looks like in your Delivery Outcomes table, you have the column [Patient Ref Key]. Is this a Ref type column that points to your Admissions for Delivery table (in which the key column is also called [Patient Ref Key])?

I hope so. Because that will allow you to much more easily build your expression. Such as this for your first Initial Value expression:

IFS( [Patient Ref Key].[Pulmonary oedema] , “Pulmonary oedema” )



Now if you were wanting to set multiple items as the initial value for a EnumList type column, you’d need your Initial Value expressions to result in a List type. We can try the following, though I’m not 100% positive that it will work without testing it.

LIST(
  IFS( [Patient Ref Key].[Pulmonary oedema] , "Pulmonary oedema" ) ,
  IFS( [Patient Ref Key].[ICU Admission] , "Intensive care admission" ) ,
  ...
  )


Also notice how I’m referring to a YES/NO type column directly in order to get a TRUE/FALSE value to return as the condition for the IFS() expression. This is equivalent to comparing the column against ‘Y’.

Hi, Thank you very much @March_Dillon for your reply.

Actually, “Delivery Outcomes” table and “Admissions for Delivery” table are not mother/child tables, instead, both of them are child tables of a mother table called “Patient Bank”. Both “Delivery Outcomes” and “Admissions for Delivery” tables have a [Key] column as the Key column, and [Patient Ref Key] column that references each of them to the “Patient Bank”. So for a particular patient, the [Patient Ref Key] in both of these tables are always the same value.

Therefore, IFS( [Patient Ref Key].[Pulmonary oedema] , “Pulmonary oedema” ) wouldn’t work in my case.

Unfortunately, I couldn’t get the initial value of the EnumList type column to preselect several values based on the data in other tables.

The thing is, the following expression is accepted by AppSheet, but it’s just that it would only preselect the first expression in the IFS (as in only the “Pulmonary oedema”), and the other one doesn’t get selected even if the condition is true.

Blockquote

IFS((CONTAINS(SELECT(Admission for Delivery[Pulmonary oedema], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Pulmonary oedema”,

(CONTAINS(SELECT(Delivery Outcomes[ICU admission], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Intensive care admission”)

If I swap the first IFS with the second IFS, and writes the expression as…

Blockquote

IFS((CONTAINS(SELECT(Delivery Outcomes[ICU admission], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Intensive care admission”,

(CONTAINS(SELECT(Admission for Delivery[Pulmonary oedema], [_THISROW].[Patient Ref Key] = [Patient Ref Key]),Y),“Y”),“Pulmonary oedema”)

…then the “Intensive care admission” in the EnumList gets highlighted (as in preselected), but the “Pulmonary oedema” wouldn’t.

Anyway, I created a few virtual columns inside the “Delivery Outcomes” table where each of them gets filled by a value “Y” if the conditions in different tables are fulfilled, and then wrote an expression to the initial value of the EnumList column as in

Blockquote

IFS([Pulmonary oedema_VC]=“Y”,“Pulmonary oedema”,[Intensive care admission_VC]=“Y”,“Intensive care admission”)

but still, only the first one gets highlighted in the EnumList column. I even made a LIST as you suggested, but still, it returned the same.

So I’m thinking if it’s not possible to automatically preselect multiple values in an EnumList column (via “initial value”) in AppSheet? Would value your opinion.

@Steve @Aleksi @Suvrutt_Gurjar

It definitely is. I’m afraid I’m not inclined to read through everything above to try to figure out what you want. Can you boil it down to a few sentences?

Thanks a lot @Steve for solving the issue on the other thread. Sorry for opening 2 threads on that. Will refrain from doing that in the future.

  1. SELECT(Delivery Outcomes[ICU admission], [_THISROW].[Patient Ref Key] = [Patient Ref Key]) returns a list
  2. CONTAINS(<.list.>, Y) returns Y/N I believe will technically work, but is poorly formatted, and I’m pretty sure it is also inefficient.
  3. (<.Y/N.>, “Y”) ??? I have absolutely no idea how this gets interpreted or the end result.

More of less, the same for the other one. Your expression to me boils down to
IFS( ???, “Pulmonary oedema”, ???, “Intensive care admission”)
Which won’t produce a list even if the individual expressions DO actually work as you want them to, because per the IFS() documentation that @Marc_Dillon linked to:

So IFS() can only result in one thing. And if it isn’t in list format at least similar to @Marc_Dillon’s suggestion, then multiple won’t be pre-selected. Ever.

Patient Bank should have a Related Admission for Deliveries and Related Delivery Outcomes VCs.
Therefore, I think this is doable nowadays but I haven’t fully played with this concept within AppSheet:

LIST(
   IFS(OR([Patient Ref Key].[Related Delivery Outcomes][ICU admission]), "Intensive care admission”),
   IFS(OR([Patient Ref Key].[Related Admission for Deliveries][Pulmonary oedema]), “Pulmonary oedema”)
)

You may need to tweak my spelling for those Related columns. Not sure how AppSheet actually named them.

Thank you very much for your reply on this. I know my expression was a poor choice for this particular purpose. I tried your method, but it didn’t work.

Anyway, @Steve managed to solve it.

Thank you very much for all the replies! AppSheet’s community support is simply the best!

Top Labels in this Space