cancel
Showing results for
Did you mean:
Post Prodigy

Calculate total amount per quantity enter

Under some pressure. What would be the correct formula to calculate total amount per Quantity

Here my SharePoint List call -

PowerApps - l'm able to get the total sum on the whole "Price" Column

Trying to figure out the right formula when user input the number of Quantity it equal to the Total Amount

Hope i explain myself clearly.

Thank you so much in advance

1 ACCEPTED SOLUTION

Accepted Solutions
Super User

Hi @oappdev

You can set the configuration like:

Since each item has its own cost, you need to get the value directly from the datasource as:

Set(ItemPrice, LookUp(DataSourceName, ProductName = ProductCombobox.Selected.ColumnName).Price)

Now, to patch the results, you can use the expression:

Patch(DataSource, Defaults(DataSource),{Col1:"Value1", Col2:"Value2", Price: Value(DataCardValue1.Text)*Value(ItemPrice)})

Note: Instead of passing all the columns in separate curly brackets, you can pass them all in a single curly bracket separated by comma.

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
10 REPLIES 10
Community Champion

If the price would not be dynamic, then set a variable; Set(UnitPrice,49.59).

Then in the total, put: UnitPrice*Quantitytxt

Post Prodigy

@eka24 Thank you so much. Will give it a try and circle back

Post Prodigy

@eka24 Stupid question. I have created the variable Set(UnitPrice,49.59)

l'm using a Patch() to add to my gallery. How would l apply the variable to Patch()?

Having fun learning something new everyday from PowerApps

Community Champion

Set(UnitPrice,49.59);
Patch({Put all the formula.........)

Replace the price with-  Price: Value(Datacardvalue1.Text)* UnitPrice

Super User

Hi @oappdev

You can set the configuration like:

Since each item has its own cost, you need to get the value directly from the datasource as:

Set(ItemPrice, LookUp(DataSourceName, ProductName = ProductCombobox.Selected.ColumnName).Price)

Now, to patch the results, you can use the expression:

Patch(DataSource, Defaults(DataSource),{Col1:"Value1", Col2:"Value2", Price: Value(DataCardValue1.Text)*Value(ItemPrice)})

Note: Instead of passing all the columns in separate curly brackets, you can pass them all in a single curly bracket separated by comma.

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Post Prodigy

Thank you so much @yashag2255

Question

I when and add the following to OnStart is this correct

``Set(ItemPrice, LookUp(DataSourceName, ProductName = ProductCombobox.Selected.ColumnName).Price)``

Super User

Hi @oappdev

I would recommend you to add it on the "OnChange" property of the dropdown/combobox control, where you are providing the user to select the Product Name choice, that way whenever the product is changed, the variable reflects to its price.

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Most Valuable Professional

OnStart does not run in the PowerApps Maker previewer by default - only the published App's player. To run OnStart during app editing, You may want to put it in OnVisible of the first screen (remember to toggle screens back and forth when testing). Or, remember to, from PowerApps maker, press the OnStart and press "Run OnStart" or else it won't run.

Super User

Adding the expression on the "OnStart" or "OnVisible" property of the App and screen respectively, will not be working in the case when a product is changed from the products dropdown as each item has its own price and it is not fixed on a certain value.
OnStart/OnVisible is not triggered when user changes input on the screen, that is why OnChange property would be the best choice in my opinion.

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Announcements