cancel
Showing results for
Did you mean:
Highlighted
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 -

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
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!
10 REPLIES 10
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

Level 8

## Re: Calculate total amount per quantity enter

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

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

Level 10

## Re: Calculate total amount per quantity enter

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

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

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!
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

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

## Re: Calculate total amount per quantity enter

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

## Re: Calculate total amount per quantity enter

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

Check it out!

Check it out!

#### Power Apps Community User Group Member Badge

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

#### Power Platform World Tour

Find out where you can attend!

#### Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

#### Difinity Conference

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

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