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 Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (3,330)