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

Calculating dynamically

Hi Experts,

 

I have an edit form in which there are many data cards and the four in context are price per unit, quantity, discount percentage and total discount.

I am trying to write a formula that will get executed anywhere but before saving the form that will calculate the Total Discount, based on the other three data card. I have got the formula figured out

 

'Price Per Unit_DataCard1'.Default*Quantity_DataCard4.Default*'Discount %_DataCard5'.Default/100

 

but not able to get it executed, i have tried to put in the default of the the datacard or onsave of the form but i am not able to get it executed(or applied in the DB). If i change the quantity or discount percentage it gets saved in the DB but the Total Discount is not until i go to the same record to edit. At that time on the onload of the edit form, the Total Discount gets calculated waiting for me to just save and then it goes to the DB.

 

So i have found out that its not getting executed during onsave but onload the next time. How do i overcome this. Please help.

 

Thanks in advance for your response.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User II
Super User II

@Davy1 

I'm not sure that I understand your issue.  PowerApps acts much like an Excel spreadsheet in that calculations are done on the fly.  I don't know the actual type of controls represented by your datacards but within an Edit form, they are usually named DataCardValue1, etc.  and they represent the actual value.  You can use the names for the calculation.  For any particular calculated field in a form, you can  putting the formula in another card as Default property of the control in the calculated fields card

 

With({ppu: DataCardValue15
      qty: DataCardValue16
      dsc: DataCardValue17
      },
    ppu*qty*dsc/100
)

 

1.jpgIn the example, the actual names of the controls in the form (datacardvaluexx) are used to create a default property for the textinput box in the Profit card

View solution in original post

2 REPLIES 2
Drrickryp
Super User II
Super User II

@Davy1 

I'm not sure that I understand your issue.  PowerApps acts much like an Excel spreadsheet in that calculations are done on the fly.  I don't know the actual type of controls represented by your datacards but within an Edit form, they are usually named DataCardValue1, etc.  and they represent the actual value.  You can use the names for the calculation.  For any particular calculated field in a form, you can  putting the formula in another card as Default property of the control in the calculated fields card

 

With({ppu: DataCardValue15
      qty: DataCardValue16
      dsc: DataCardValue17
      },
    ppu*qty*dsc/100
)

 

1.jpgIn the example, the actual names of the controls in the form (datacardvaluexx) are used to create a default property for the textinput box in the Profit card

View solution in original post

Thank you so much for the response, apologies i was not able to get back to you. Yes, the mistake i did was, i used the datacard but actually should have used datacardvalue for each datacard as you mentioned. Thank you very much again

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (52,059)