cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Titiwai
Helper II
Helper II

Looking for an elegant solution to display sum in app

I have say a list with about 20 numeric fields, after submit the form I want to display the sum in the app.

 

Button OnSelect

SubmitForm(Form1);

ClearCollect(colSum1,Filter(Table_2,BU=varBU,Till=Label1_3.Text,Delegate_Date=varDelgateDate));
ClearCollect(colSum2,Filter(Table_2,BU=varBU,Till=Label1_1.Text,Delegate_Date=varDelgateDate));
ClearCollect(colSum3,Filter(Table_2,BU=varBU,Till=Label1_2.Text,Delegate_Date=varDelgateDate));
ClearCollect(colSum4,Filter(Table_2,BU=varBU,Till=Label1_7.Text,Delegate_Date=varDelgateDate));
ClearCollect(colSum5,Filter(Table_2,BU=varBU,Till=Label1_8.Text,Delegate_Date=varDelgateDate));
ClearCollect(colSum6,Filter(Table_2,BU=varBU,Till=Label1_9.Text,Delegate_Date=varDelgateDate))

 

And there are two columns of labels setting up:

 

Naming Label runs if statement to go through different naming conventions for each BU

If(varBU="A","A1",If(varBU="B","B1",If(varBU="C","C1",If(varBU="D","D1",))))

 

Total Label calculates the total based on per Label name:

Sum(Filter(colSum1,BU=varBU),'100_Dollar')+Sum(Filter(colSum1,BU=varBU),'50_Dollar')+Sum(Filter(colSum1,BU=varBU),'20_Dollar')+Sum(Filter(colSum1,BU=varBU),'10_Dollar')+Sum(Filter(colSum1,BU=varBU),'5_Dollar')

 

Right now they look so bulky and I am not even sure how it is going to take to run the collection.

Looking for a better alternative.

1 REPLY 1
v-xida-msft
Community Support
Community Support

Hi @Titiwai ,

Could you please share a bit more about your scenario?

Do you want to sum 20 numeric fields of the submitted record after you submit your form data successfully?

 

If you want to sum 20 numeric fields of the submitted record after you submit your form data successfully, I think it is not necessary to use complex formula as you mentioned. Please take a try with the following workaround:

Set(TotalValue, Form1.LastSubmit.NumberColumn1 + Form1.LastSubmit.NumberColumn2 + Form1.LastSubmit.NumberColumn3 + Form1.LastSubmit.NumberColumn4 + ... + Form1.LastSubmit.NumberColumn20)

then you could use the TotalValue variable in your app.

 

If you just want to calculate the Total value based on the colSum1, colSum2, ... colSum6, Please modify your Total Label formula as below:

Sum(colSum1,'100_Dollar')+Sum(colSum1,'50_Dollar')+Sum(colSum1,'20_Dollar')+Sum(colSum1,'10_Dollar')+Sum(colSum1,'5_Dollar')

 

If you could provide more details about your scenario, we could provide a proper workaround for you.

 

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

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (28,415)