Want to increase count in a columns when I click a button


I am new to retool.

I am trying to understand how can I simply add 1 to count each time someone clicks a particular button. This will be row specific operation

Thank you

Hey @Kowshik_Bokka, welcome to the community :hugs:

That's definitely possible :)) A high level overview would be:

  • Populate the table with your data
  • Select a row
  • Create a button
  • Create a JS Query that:
    • takes the table.selectedRow data and applies the incremental logic to the value
    • then sends that data to another query that updated your database
  • Create a new query that:
    • updates your database with the new value

Hope that helped. If you're stumbling into issues post back with some screenshots and what you've tried so far.

Hi @minijohn

Thanks for the idea.

I was able to solve it.

1 Like

Hi @Kowshik_Bokka ,

I have the same requirement as you but I am unable to figure it out. Can you please help me out with this?


Hi @aditya_1, It looks like Kowshik_Bokka was able to use the increment operator in an update query to Google Sheets to update the value in their case. Could you share the specifics of what you're building and the behavior you're seeing?

1 Like

Hi @everett_smith ,

I was able to crack it.


I’m trying to figure out how to do this with the query gui for retool database. I already have a trigger and it updates the column cell to 1. But I want it to add 1. I thought maybe the column name “quantity + 1” or just ++. But it parses a string. Any ideas?

I’m using “insert or update”.

Looking for increment on current value..

Thank you!

Hey @BobandBill, You could just pass the current value + 1 in the GUI query. Here's a screenshot and also a JSON export of an app with an example of how that could work!

You can import the attached JSON file by clicking Create new (home page) > From JSON.


1 Like

Thanks for this example. But this means you’ll have to have a table and selectedRow and also “number_to_be_incremented” in that table. What if I just want to use {{number_to_be_incremented}} +1 ? Because I don’t have that database table loaded. The filter I supply with variables from other parts of the app, not from a table component where the table data from the database was used as a resource.

Kind regards

Solved it. Just {{ }} + 1 or -1. Works :sweat_smile: