cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

Grand Total in a Gallery

I have a gallery with a collection for my data collection.

 

I have a row with quantity and cost. These two fields get multiplied together in to an extended cost field. That is working just fine but I have another field at the bottom that shows a grand total which should be the sum of all the extended cost fields.

 

My problem is that I can't add my Extended Cost field to my collection because my Default property has the multiply function (Quantity * Unit Cost). Is there any way to add a field (extended cost) to a Collection as well as add the result of my multiplication (extended cost) to the same collection?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

I got it!. I created a variable and then put my Total Cost in there.

 

Set(RunningCost, ExtendedCostInput + DataCardValue1)

 

Then I set my DataCardValue1 to show the RunningCost.

 

This is working beautifully - thank you both for all your help.

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

Hi @itguy123 

The general way to approach this is to set the Items property of your gallery to a formula that looks something like this:

AddColumns(YourCollection,
           "ExtendedCost",
           Quantity * Cost
)

Within your gallery, you can then display the extended cost by adding a Label and setting the Default property of the control to ThisItem.ExtendedCost.

Outside your gallery (assuming that your gallery is called Gallery1), you can then display the grand total of extended cost using this:

Sum(Gallery1.AllItems, ExtendedCost)
Highlighted
Community Support
Community Support

Hi @itguy123 ,

Do you want to add a Extended Cost field within your existing Collection with multiplication value (Quantity * Unit Cost)?

 

Currently, within PowerAps, there is no direct way to add a new column into a existing Collection. As an alternative solution, you could consider create a new collection based on your existing collection along with the new Extended Cost field.

 

I have made a test on my side, I think the AddColumns function could achieve your needs. Please consider take a try with the following workaround (set the OnVisible property of current screen to following😞

ClearCollect(
               NewCollection,
               AddColumns(
                            YourExistingCollection,
                            "Extended Cost",
Quantity * Unit Cost ) )

then you could use the NewCollection as a data source within your app.

 

In addition, if you want to calculate the sum of all the Extended Cost fields within the NewCollection, please take a try with the following formula:

Sum(NewCollection, "Extended Cost")

 

In addition, you could also get the sum of all the extended cost fields directly, please take a try with the following workaround:

Set the Text property of the Label to following (on your side, please set the Default property of another field at the bottom to following😞

Sum(
       AddColumns(
                     YourExistingCollection,
                     "Extended Cost",
                     Quantity * Unit Cost
         ),
        "Extended Cost"
)

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

Thank you both for your quick responses, I really appreciate it. I hit a couple of problems but I know we're getting close. Let me provide a little more information about my situation.

 

The Quantity field and Unit Cost field are input fields - so a user would enter Quantity and Unit Cost and the two get multiplied to give the Extended Cost.

 

@v-xida-msft Using the OnVisible property only calculates the extended cost when the screen loads before a quantity and unit cost have been entered. Is there somewhere else I can place this function so the extended cost field gets calculated when those fields are populated?

 

Thanks you again for all your help,

 

ITGuy123

Highlighted

I got it!. I created a variable and then put my Total Cost in there.

 

Set(RunningCost, ExtendedCostInput + DataCardValue1)

 

Then I set my DataCardValue1 to show the RunningCost.

 

This is working beautifully - thank you both for all your help.

View solution in original post

Highlighted

Hi @itguy123 ,

Have you solved your problem?

 

If you have solved your problem, please go ahead to click the "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,445)