cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
oappdev
Post Prodigy
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 - 

List.PNG

 

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

Quantity.PNG

 

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

Quantity_Price.PNG

 

Hope i explain myself clearly. 

 

Thank you so much in advance

1 ACCEPTED SOLUTION

Accepted Solutions
yashag2255
Dual Super User II
Dual Super User II

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!

View solution in original post

10 REPLIES 10
eka24
Super User
Super User

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

Then in the total, put: UnitPrice*Quantitytxt

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

@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

 

Patch.PNG

 

Thank you in advance

Onselect of AddButton:

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

 

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

yashag2255
Dual Super User II
Dual Super User II

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!

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)

 

yashag2255
Dual Super User II
Dual Super User II

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!

@oappdev 

 

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.

@oappdev 

 

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!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (3,024)