It depends.
- are the +/- buttons part of a gallery of items whose quantity changes or is it a single variable?
- do you need to save the variable to the datasource right away?
If the +/- buttons are changing a just one variable for a Screen, then use UpdateContext:
Button1: UpdateContext({quantity: quantity+1})
Button2: UpdateContext({quantity: quantity-1})
Note: Or if you want the variable to be global, then use a Collection instead of a UpdateContext.
If the +/- buttons are repeated as part of a gallery or collection, configure the +/- buttons to change the values of the datasource itself.
Button1: Patch(datasource,ThisItem,{quantity: ThisItem.quantity+1})
Button2: Patch(datasource,ThisItem,{quantity: ThisItem.quantity-1})
If you need to save the quantity immediately upon making any changes, then Patch() the changes right away.
If you can wait to apply all changes at once, then Collect the changes as you add or subtract and Patch the changes afterwards.
ForAll(changes,
Patch(datasource,[identify each row],
{quantity: quantity
}
)
)Note: you may need to use disambiguation or RenameColumns since the column "quantity" has the same name.