cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
oappdev
Level 8

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
Dual Super User
Dual Super User

Re: Calculate total amount per quantity enter

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
Level 10

Re: Calculate total amount per quantity enter

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

Then in the total, put: UnitPrice*Quantitytxt

oappdev
Level 8

Re: Calculate total amount per quantity enter

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

oappdev
Level 8

Re: Calculate total amount per quantity enter

@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

eka24
Level 10

Re: Calculate total amount per quantity enter

Onselect of AddButton:

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

 

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

Dual Super User
Dual Super User

Re: Calculate total amount per quantity enter

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

oappdev
Level 8

Re: Calculate total amount per quantity enter

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)

 

Dual Super User
Dual Super User

Re: Calculate total amount per quantity enter

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!
dynamicsedge
Level 8

Re: Calculate total amount per quantity enter

@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.

Dual Super User
Dual Super User

Re: Calculate total amount per quantity enter

@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
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,010)