cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PowerAid
Level: Powered On

Getting Subtotal Value with Collection columns set at Default property.

I have a repeating table with Amount Each, Quantity, and Subtotal.  These fields write to a collection.  The Default property for these fields are set to the collection's corresponding columns: AmountEachCC, QuantityCC, and SubtotalCC.  My subtotal field is currently a text input control.  I need it to calculate the Amount Each * Quantity fields.  Normally, I would enter in the Default property of the subtotal field QuantityCC * AmountEachCC but I can't since it is set to SubtotalCC so it can write that value to the collection.   I hope this makes sense.  Any ideas on how I can get the calculation to work?

1 ACCEPTED SOLUTION

Accepted Solutions
PowerAid
Level: Powered On

Re: Getting Subtotal Value with Collection columns set at Default property.

I figured it out! I decided to make all of my collection columns end in "CC" just to help me differentiate them from the SharePoint list fields so AmountEach would be AmountEachCC or QuantityCC. Anyways, instead of making the Default property of the Subtotal text input control be the corresponding collection column (SubtotalCC), I made it TextInputAmountEach*TextInputQuantity. Then on the OnSelect code for the Save icon, I made the Subtotal collection column this: SubtotalCC: Value(TextInputAmountEach*TextInputQuantity) The whole code for my OnSelect property for the Save icon is this:Patch(RevenuePreDefinedCollection, ThisItem, {CategoryCC: DropdownPreDeifinedCategories.Selected.Value, AmountEachCC: Value(TextInputAmountEach.Text), QuantityCC: Value(TextInputQuantity.Text), SubtotalCC: Value(TextInputAmountEach*TextInputQuantity)}); Collect(RevenuePreDefinedCollection, {CategoryCC: "Select...", AmountEachCC: 0, QuantityCC: 0, SubtotalCC: 0})

View solution in original post

4 REPLIES 4
egallis
Level 10

Re: Getting Subtotal Value with Collection columns set at Default property.

Hi @PowerAid,

Your post (probably) makes sense but it's a bit hard here to figure out exactly your situation :). A screen capture showing us the various elements you describe would be very helpfull.

Waiting for your feedback...

PowerAid
Level: Powered On

Re: Getting Subtotal Value with Collection columns set at Default property.


@egallis wrote:

Hi @PowerAid,

Your post (probably) makes sense but it's a bit hard here to figure out exactly your situation :). A screen capture showing us the various elements you describe would be very helpfull.

Waiting for your feedback...


My PowerApp is a budget proposal form.  It connected to a Master Sharepoint list that stores each request and it also has a secondary list that stores all of the child entries for the repeating table.  I am using a gallery as the interface for the repeating table.  The home screen has a button called Create new Budget proposal. OnSelect, it creates a new collection for the repeating table.  Here is the code:

NewForm(Form1);ClearCollect(RevenuePreDefinedCollection, {CategoryCC: "", AmountEachCC: 0, QuantityCC: 0, SubtotalCC: 0}) ;Navigate(NewItem,ScreenTransition.Cover)

 

The columns in this collection corespond to the text inputs in the repeating table (gallery).  There is a Save icon next to each gallery entry.  It has the following code:

Patch(RevenuePreDefinedCollection, ThisItem, {CategoryCC: DropdownPreDeifinedCategories.Selected.Value, AmountEachCC: Value(TextInputAmountEach.Text), QuantityCC: Value(TextInputQuantity.Text), SubtotalCC: Value(TextInputSubtotal.Text)}); Collect(RevenuePreDefinedCollection, {CategoryCC: "Select...", AmountEachCC: 0, QuantityCC: 0, SubtotalCC: 0})

 

Then once you have all of your revenue entries added, you click on the main Save button which writes the form to SharePoint and writes the child entries to the details list.  The code for the Save button is: SubmitForm.Form1

The OnSuccess of the form is where the main code comes into play.  It looks like this:

ForAll(Filter(RevenuePreDefinedCollection,CategoryCC<>"Select..."), Patch('Revenue Pre-Defined Categories', Defaults('Revenue Pre-Defined Categories'), {Title: CategoryCC, AmountEach: AmountEachCC, Quantity: QuantityCC, Subtotal: SubtotalCC, MasterID: Form1.LastSubmit.ID}))

 

I have attached some screen shots to help explain this.  The Default values of the text inputs in the gallery have to be set to the coresponding columns in the collection.  Then the collection writes the values to the details sharepoint list(RevenuePreDefinedCollection).  My issue is that I need the subtotal text input to be Amount*Quantity.  I would normally place that in the Default property of Subtotal but that is where I have the collection column SubtotalCC. 

 

 

 

 

PowerAid
Level: Powered On

Re: Getting Subtotal Value with Collection columns set at Default property.

I figured it out! I decided to make all of my collection columns end in "CC" just to help me differentiate them from the SharePoint list fields so AmountEach would be AmountEachCC or QuantityCC. Anyways, instead of making the Default property of the Subtotal text input control be the corresponding collection column (SubtotalCC), I made it TextInputAmountEach*TextInputQuantity. Then on the OnSelect code for the Save icon, I made the Subtotal collection column this: SubtotalCC: Value(TextInputAmountEach*TextInputQuantity) The whole code for my OnSelect property for the Save icon is this:Patch(RevenuePreDefinedCollection, ThisItem, {CategoryCC: DropdownPreDeifinedCategories.Selected.Value, AmountEachCC: Value(TextInputAmountEach.Text), QuantityCC: Value(TextInputQuantity.Text), SubtotalCC: Value(TextInputAmountEach*TextInputQuantity)}); Collect(RevenuePreDefinedCollection, {CategoryCC: "Select...", AmountEachCC: 0, QuantityCC: 0, SubtotalCC: 0})

View solution in original post

egallis
Level 10

Re: Getting Subtotal Value with Collection columns set at Default property.

Glad you could find a solution !

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 130 members 5,320 guests
Please welcome our newest community members: