Use Info on submitted form as value to change on another row

I have an action set to โ€œData: execute an action on a set of rowsโ€. I can reference the row I want to edit, thatโ€™s fine and working. I have then made another action that is called by this one in the โ€œreferenced Actionโ€ drop down.

In this action I would like to use a value in the form that was just submitted (so the last row in the table) and replace a value in the row that was referenced in the initial action. They are in 2 different columns but I donโ€™t think that makes a difference. This is all on the same table.

I can easily set the value in the column (in the row to be edited) to be changed to just a random number so I know its all working fine upto that point.

The problem comes when I try to get the value from the last row and use that. If I use [_THISROW].[Column_To_Get_Value_From] or just [Column_To_Get_Value_From], it will use the value from the row that I want to edit, not the last row (the one that trigged the action).

I have used various attempts as MAXROW(), LOOKUP(), SELECT() but canโ€™t get anything to work. Iโ€™m sure this should be easy, I just need to to get the value from the last (bottom) row and use that. The closest I got was to make it find the MAX value from the [Column_To_Get_Value_From] and insert that, but as the values wont be in any sort of order, it needs to be the very last row, simple as that!

Iโ€™m sure this isnโ€™t as hard as Iโ€™m finding it, spent 6 hours trying to get it to work!

Any help would be great.

Rob.

Solved Solved
1 9 722
1 ACCEPTED SOLUTION

Sorry, please try

ANY(SELECT(Table Name[Column_To_Get_Value_From], [Key Column of the table]=MAXROW(โ€œAPP Fuel Truck Form โ€, โ€œ_ROWNUMBERโ€)))

View solution in original post

9 REPLIES 9

Hi @AviSyst_Admin
Did you try some thing like this.

Yep, It gives the following error:

The expression is valid but its result type โ€˜Refโ€™ is not one of the expected types: Number

I also tried

MAXROW(โ€œAPP Fuel Truck Form โ€, โ€œ_ROWNUMBERโ€).[Column_To_Get_Value_From]

and I get the same error.

So I can find the row as a reference, but canโ€™t seem to โ€œconvertโ€ that to a row number or a reference I can use.

Have not properly understood all the details.

However the above could be possibly achieved by

SELECT(Table Name[Column_To_Get_Value_From], [Key Column of the table]=MAXROW(โ€œAPP Fuel Truck Form โ€, โ€œ_ROWNUMBERโ€))

But please note that this will be an inherently sync time expensive expression, especially for a table with large number of rows.
Depending on app design, you may try a dual step approach. Acolumn that calculates MAXROW() first and then using that column to get the value of [Column_To_Get_Value_From] using dereference expression.

That gave me the error:

โ€œThe expression is valid but its result type โ€˜Listโ€™ is not one of the expected types: Numberโ€

Iโ€™ve tried variations of what youโ€™ve suggested and always got this error or the previous one (โ€œThe expression is valid but its result type โ€˜Refโ€™ is not one of the expected types: Numberโ€.

Your second suggestion is what Iโ€™m trying to achieve but by using actions. Not sure I know how to do what your suggesting using actions?

Rob.

Sorry, please try

ANY(SELECT(Table Name[Column_To_Get_Value_From], [Key Column of the table]=MAXROW(โ€œAPP Fuel Truck Form โ€, โ€œ_ROWNUMBERโ€)))

Nailed it,

THANK YOU so much. Now Iโ€™ll go about to figure out why that works and move onwards and upwards.

Cheers,

Rob.

You are welcome. Sure,. The way you have posted earlier updates, I believe you are familiar with how all the relevant AppSheet functions work in the shared expression.

Please post back in case of any specific query.

Steve
Platinum 4
Platinum 4

For reference:

Thanks Steve,

Thatโ€™s very handy to have as a reference.

Rob.

Top Labels in this Space