Price calculator

Hello everyone, I'm planning to create an app where i can encode list of products and at the same time retrieve the price from my google sheet and show it in line with the product, but multiply it by the value of quantity encoded. im stuck on the part on how to retrieve data from google sheet. thanks everyone

You can do this

or this

to get data back from your google spreadsheet, set as "Anyone with the link can view" permission

1 Like

It's important to realize that you will need more than one sheet for this.

  • A price sheet with the item names or codes in column A and the associated unit price in a second column
  • A purchase sheet to assign a unique id to each purchase and summarize its payment and completion
  • A cart items sheet to list the type and quantity of each item in each cart, one item per row

Once you have this, look in the Google Sheets online help for the =VLOOKUP() function

If your items sheet is small enough, download it once and learn how to use a lookup table

Search this board for

  • FAQ Google Sheets
  • FAQ lists
  • Marathon sample app
1 Like

thank you so much good sirs.. will look on it and study


how can i convert my my query formula into this as part of the link sir? query(B2:F21,"select F where B matches "value from variable")

fixed* I'm kinda lost here sir.. it display 1 row above the desired result

Like so:

You may want to swap the B = for B CONTAINS ?

https://docs.google.com/spreadsheets/d/1IdpGILd7Nii8nq5yb2Qu3kVFyyL50eo5la2xbDN1Cok/gviz/tq?tqx=out:csv&sheet=myData&range=B2:F21&tq=SELECT F WHERE B CONTAINS 'fruit'

i mean, from regular formula into something like the code in the link after &tq=SELECT+Aetc.etc. sir.

Do I not show that ?

image

i want to skip that part sir, the 2nd text line and incorporate it in the first web link instead.

ohhh.. im very sorry sir, this answer my question.. i never thought that we can write it like this.. because what i saw in the tutorials are not like this.. sorry sir and thank you..i thought we need to convert the formula into uriEncode

You may well need to uriEncode it!

1 Like


im trying to multiply the quantity encoded and the responseContent from query, i already set the format from my sheet into number, but cannot be read as number in mit?how to convert responseContent into decimal sirs?

Look at your responseContent in a label


this is how i interpreted your hint sir.. but still getting the error.. i tried to use to decimal, but cant figure how to put the value of the variable as its value

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Taifun

1 Like

thank you for this sir.. i think the "" marks on response makes the multiplication impossible. how to simply remove the "" sir?

This question would be easier to answer if we were to see what got put into Label2.Text

From the error message, under extreme magnification, I see the inputs to the multiplication as ""260"" and "1"

That double double quote sequence looks fatal to math blocks.

Use the replace text block to change all " to the empty text block, on the way into the * math block.

Here's an inline procedure for that:
image


(draggable)

The + 0 was needed to prove the result was a number and to force it into a numeric type internally.

1 Like

This sample app shows how to do price multiplication in a single cart, using TinyDB.

It introduces the idea of a table lookup and the idea of keeping the cart separate from the menu.

1 Like

thank you so much for this sir.. i find it harder to learn to follow other's idea from what i want to produce, so i try as much as possible to learn each steps i need to come up to what i need. thank you for this sir.


it's working very well as i want it sir.. thank you so much

On investigation, when calling back a single cell value using gviz, you can resolve the extra double quoting as follows:

If calling back single values from multiple rows:

1 Like

thank you so much sir, i can use it later on my projects.