How to update one fields in other table

Hello,

I have two tables gifts and perso.
Gifts contains two fields points and sells, when increment sells, i need update perso.points. the formula for update perso.points is perso.points - gifts.points.

The increment work, but i can’t update perso.

Thk’s

Hi @Laurent_Stiens

You may want to prefer using Virtual Column instead of real column.
This way, the calculation made will always be correct, depending on current values you set on your two tables.

I suggest:

  • remove your current “total points” from your sheet.
  • then regenerate structure in the table panel
  • add virtual column in the table panel, name it “total points”, and set your formula there.

Please see also:

Let us know if that works for you.

2 Likes

Hello, this alternative don’t work…

@Laurent_Stiens

Can you please share screenshot of your table structures and the formula you use ?

1 Like

When i click on dollars the field slavetrackersPoints of table slavetrackers set slavetrackers[slavetrackersPoints] = slavetrackers[slavetrackersPoints] - gifts[giftsPoints]

The table slavetrackers contains just an unique row

OK, thank you for giving more context.

I’m afraid the formula you use is not correct.
This: slavetrackers[slavetrackersPoints] is a list of values.
because of it,this expression: slavetrackers[slavetrackersPoints] - gifts[giftsPoints] is a list type, operating a list subtraction.

If you want to get a number, you may prefer using:
SUM(slavetrackers[slavetrackersPoints]) - SUM(gifts[giftsPoints])

I don’t see any virtual column on your screenshot, did you cut the snap ?
Furthermore, I don’t see the relation between your two tables on the screenshots ? (this is a virtual column as well)
Also, can you please show your action setting with the “dollar” button ?

2 Likes

This is action with “dollar” button :

If you choose one “gifts” the slavetrackersPoints is update with the value Point of gifts selected.

I remove the virtual colunm on gifts table

there is no relationship between the two tables, gifts is multiline and slavetrackers is of type one row

I’m sorry, I’m not sure of getting what you want to achieve.

When i click on dollars the field slavetrackersPoints of table slavetrackers set slavetrackers[slavetrackersPoints] = slavetrackers[slavetrackersPoints] - gifts[giftsPoints]

This is in contradiction with the screenshot of your action “Acheter”.

If you choose one “gifts” the slavetrackersPoints is update with the value Point of gifts selected.

This goes to my first question: what is the relation between your two tables ? You must have one column in the slaveTracker Table referring to your Gifts Table. Otherwise, you cannot specify which item you refers in your sum.

I suggest you have a look to this sample app, just click on “Look under the hood” button.
This is a basic app, and the column “Total Stock Available” in the Table Items will reveal the main interest of the virtual column.
Also, the Item ID in the Inventory Table, which refers to the Items table.

Let us know if that helps you

2 Likes

Hello, thk’s for the link’s but this does not correspond to what I want to do.

I would like this app https://obedienceapp.com/ on google sheet with appsheet.

Can you help me ?

The link I shared was for “education” purpose :slight_smile:

I’m sure you can do it with time, I will contact you in MP as well.