Initial value will not populate

tvinci
New Member

Hello AppSheet Community

I am attempting to have a field in my form prepopulated, so I wrote this expression, but the field still will not be prepopulated. What did I do wrong?

Thanks.
Tiffany

ifs(index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜4Cโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))+1) , โ€˜1Aโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜1Aโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜1Bโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜1Bโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜1Cโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜1Cโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜2Aโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜2Aโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜2Bโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜2Bโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜2Cโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜2Cโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜3Aโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜3Aโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜3Bโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜3Bโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜3Cโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜3Cโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜4Aโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜4Aโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜4Bโ€™),
index(split(agid test entry[well position],โ€™-โ€™),2)=โ€˜4Bโ€™,
concatenate((max(extractnumbers(index(split(agid test entry[well position],โ€™-โ€™),1)))) , โ€˜4Cโ€™),
)

Solved Solved
0 4 309
1 ACCEPTED SOLUTION

This reminds me of a question about generating sequential invoice numbers that came up the other day. You might want to check out that thread for inspiration: Incrementing Number when its a Key / Invoice Number Generation

Do you have just a fixed set of well numbers? If so, you might want to use a lookup table that has a column for well numbers and another column for the โ€œsuccessorโ€ well number. You could then use LOOKUP() to initialize the value.

Otherwise, it might be easier to have your Well Position split into a column for each piece, so the row with 2-4C would look like:

  • Number1: 2
  • Number2: 4
  • Letter: C
  • Well Number: 2-4C

Iโ€™d also add a reference to the most recently added row. That should also help with writing your formulas. See this app for an example: https://www.appsheet.com/samples/Initialize-forms-with-most-recent-value?appGuidString=18b39921-b8a8...

Then you could write separate initial values for the columns. For example, Number1 should be incremented if the most recent row had 4C:

IF(
  AND([Most Recent Row].[Number2] = 4, [Most Recent Row].[Letter] = C),
  [Most Recent Row].[Number1]+1,
  [Most Recent Row].[Number1]
)

You could write similar formulas for the other parts, and then your Well Position initial value would be [Number1] & "-" & [Number2] & [Letter]. You could hide the columns, so the end-user doesnโ€™t see them.

Other community members might find a more concise way to do thisโ€ฆ

BTW, I think the formula you had in your post was using agid test entry[well position] incorrectly. That expression will return the entire list of values for the Well Position column.

View solution in original post

4 REPLIES 4

tony1
New Member

Hi @tvinci. I think there are two routes we could go down (1) try to debug your expression (which is pretty complex), or (2) try to think of a different way to solve your problem that doesnโ€™t involve such a complex formula.

I think itโ€™s worthwhile to try (2) before (1). Could you say a little bit more about what youโ€™re trying to do?

Hello Tony,

Thanks for your response. So, as you may or may not be able to guess from the expression, I have a list of โ€œWell Positionโ€ values that look like this

1-1A
1-1B
1-1C


and so on. So I wanted to write an expression so that the initial value of โ€œWell Positionโ€ increments automatically while following the pattern, so that the user doesnโ€™t have to think about which Well Position to enter into the form.

This reminds me of a question about generating sequential invoice numbers that came up the other day. You might want to check out that thread for inspiration: Incrementing Number when its a Key / Invoice Number Generation

Do you have just a fixed set of well numbers? If so, you might want to use a lookup table that has a column for well numbers and another column for the โ€œsuccessorโ€ well number. You could then use LOOKUP() to initialize the value.

Otherwise, it might be easier to have your Well Position split into a column for each piece, so the row with 2-4C would look like:

  • Number1: 2
  • Number2: 4
  • Letter: C
  • Well Number: 2-4C

Iโ€™d also add a reference to the most recently added row. That should also help with writing your formulas. See this app for an example: https://www.appsheet.com/samples/Initialize-forms-with-most-recent-value?appGuidString=18b39921-b8a8...

Then you could write separate initial values for the columns. For example, Number1 should be incremented if the most recent row had 4C:

IF(
  AND([Most Recent Row].[Number2] = 4, [Most Recent Row].[Letter] = C),
  [Most Recent Row].[Number1]+1,
  [Most Recent Row].[Number1]
)

You could write similar formulas for the other parts, and then your Well Position initial value would be [Number1] & "-" & [Number2] & [Letter]. You could hide the columns, so the end-user doesnโ€™t see them.

Other community members might find a more concise way to do thisโ€ฆ

BTW, I think the formula you had in your post was using agid test entry[well position] incorrectly. That expression will return the entire list of values for the Well Position column.

I did this and it fixed it! Thank you

Top Labels in this Space