Get the maximum value from a series of rows via SELECT()

Hi

I have a table with a very simple data structure:

I have an action that creates a new row, gets the [ID] and [NOME CLIENTE] from the old. I need to automatically increase the [NUM.] value in the new row, so I want to get the maximum number of the column [NUM.] form all the rows who share the same [ID] value.

I’m currently using this formula: MAX(SELECT(Lavorazioni[Num.],ID=[_THISROW].[ID]))+1

But it doesn’t work. What am I doing wrong?

Thanks in advance for your help

Hey,

Hope you’re keeping well.

In AppSheet, your expression syntax is correct in principle, but SELECT() returns a list, so you need to ensure the data type matches what MAX() expects. If [Num.] is stored as text rather than a number, MAX() won’t work as intended. First, confirm [Num.] is a Number type in Data > Columns. Then use:


MAX(
  SELECT(Lavorazioni[Num.], [ID] = [_THISROW].[ID])
) + 1
```  

Also make sure the `[ID]` comparison is using the correct column type and matches exactly. If this runs in an initial value or App Formula for `[Num.]`, it will auto-increment based on the highest existing value for that ID.

Thanks and regards,  
Taz
1 Like

Worked perfectly, thanks

Your formatting is broken.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.