cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stumac_31
Helper III
Helper III

How to make sum autoupdate

Dear all

 

I have a timesheet app, where hours are logged against 8 dropdown fields.

On the EditScreen I have a formula to add up the total hours for the day. See e.g.1 attached

The formula result is then pulled through to the BrowseScreen using the following in the subtitle (see e.g.2 attached): 

ThisItem.Total_Hours & " " & "hours logged"

 

While it works, you have to submit the form twice for it to update on the BrowseScreen. Note in the examples attached, for Monday 2nd July on the EditScreen the total is 10 hours, while on the BrowseScreen the total is 7 hours. If I go back into the EditScreen and submit it again, it does update, but this is no good for a timesheet.

 

Can anyone think of a workaround for this? I want the value on the BrowseScreen so employees can see which days they have logged hours for, and which they have not.

 

Many thanks in advance (down to my last 2 glitches and then good to go...)

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @stumac_31,

 

Is the Total_Hours a column in your data source?

Could you please share a bit more about the Value(Hours) part within the Text formula that you mentioned in your e.g.1 attached?

 

I assume that the Total_Hours is a column in your data source, is it true? Please take a try to remove the Value(Hours) part from the Text formula that you provided, then modify the Default property of the DataCardValue5 control within your Total Hours Data Card to following formula:

Value(Hours_1_Value.Text)+Value(Hours_2_Value.Text)+Value(Hours_3_Value.Text)+Value(Hours_4_Value.Text)+Value(Hours_5_Value.Text)+Value(Hours_6_Value.Text)+Value(Hours_7_Value.Text)

 

In addition, please also take a try to add the following formula within the OnSelect property of the Submit Button control:

Refresh(datasource)

 

Please also check if the proper value has been filled into the Total_Hours column within your data source when you submit your form firstly.

 

Best regards,

Kris

 

 

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.

View solution in original post

2 REPLIES 2
CarlosFigueira
Power Apps
Power Apps

If you use the values from the data source itself instead of the current values of the controls then it should work. For example, you have this expression in your Total Hours card:

Value(Hours_1_Value.Text) + Value(Hours_2_value.Text) + ...

Assuming that Hours_1_Value is a control that is inside the Hours1 card, Hours_2_value a control inside the Hours2 card, and so on. If you select the card and look at the advanced properties, you can see (after clicking "More options") where the default value from that card comes from. In the example below, the default value of that card comes from the expression 'ThisItem.Value'. 

ForumPost001.PNG

Once you have those, then you can use those values in the expression for the total hours:

Value(ThisItem.Hours1) + Value(ThisItem.Hours2) + ...

You can use the same expression on the edit / display forms, and the browse gallery, and since it will be referencing the data source directly, anytime it's updated, the expression will be re-evaluated and the result updated as well.

v-xida-msft
Community Support
Community Support

Hi @stumac_31,

 

Is the Total_Hours a column in your data source?

Could you please share a bit more about the Value(Hours) part within the Text formula that you mentioned in your e.g.1 attached?

 

I assume that the Total_Hours is a column in your data source, is it true? Please take a try to remove the Value(Hours) part from the Text formula that you provided, then modify the Default property of the DataCardValue5 control within your Total Hours Data Card to following formula:

Value(Hours_1_Value.Text)+Value(Hours_2_Value.Text)+Value(Hours_3_Value.Text)+Value(Hours_4_Value.Text)+Value(Hours_5_Value.Text)+Value(Hours_6_Value.Text)+Value(Hours_7_Value.Text)

 

In addition, please also take a try to add the following formula within the OnSelect property of the Submit Button control:

Refresh(datasource)

 

Please also check if the proper value has been filled into the Total_Hours column within your data source when you submit your form firstly.

 

Best regards,

Kris

 

 

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.

View solution in original post

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 (2,133)