cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KhurramJamshed
Frequent Visitor

label field formula doesn't update when input field change

Hello,

Following this article: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-formulas if i sum input text fields and display through a Label field, then label field should display changes as soon input text field value change.

 

but it's not happening in my case.

 

i have a gallery with input text fields, and a formula I am using in a label field to display the sum of input text fields is:  Text(Sum(ProjectGallery.AllItems,'Year 2'),"[$-en-US]$#,###") 

 

Even if i remove formating, it still doesn't display changes as when they happen. 

Sum(ProjectGallery.AllItems,Value('Year 1'))

 

the label field only refresh sum when I patch the data after making changes and it refreshes a gallery.

 

Any idea if i am missing anything here? or how can I achieve this behavior?

 

Many thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

Not sure if this will work,  but

 

Have your sum based on the input field instead of the Gallery.   

 

So the default for the field would ThisItem.Value.  On change it is now the new value.  Have your sum field simply sum those values. not the source value.  When you patch it is will update those value now and will still be the same

 

I am note sure how the sum() will reference that field but worth a try.

View solution in original post

6 REPLIES 6
leyburn19
Memorable Member
Memorable Member

How are you changing the field in teh gallery.  If you are not patching when the change,  the default field is not updated.  the field must be update first.

 

On the on change event to the control use Patch(Source,First(Filter(Source,ID=ThisItem.ID)),{Column:Value(Textinput?.Text))

 

Source = datalist

Column= Column to change in list

 

thanks for your reply @leyburn19 

I can see what you are explaining.

I am patching, but when I have to commit the final changes of field Year1 and others.

My idea is to display sum dynamically while the user is making changes to Year1 field BUT NOT committed yet.

 

Now if the default value is not updated because i haven't patched the data yet, how else I can achieve the same result?

 

Not sure if this will work,  but

 

Have your sum based on the input field instead of the Gallery.   

 

So the default for the field would ThisItem.Value.  On change it is now the new value.  Have your sum field simply sum those values. not the source value.  When you patch it is will update those value now and will still be the same

 

I am note sure how the sum() will reference that field but worth a try.

thanks again @leyburn19 
your reply (Have your sum based on the input field instead of the Gallery.   ) has put me in the right direction, i was actually summing up the source field instead of an input text field.

and that was the reason of this issue.

Once i changed my Lable field sum formula to read the value from an input text field, it started behaving as expected.

 

 

v-yutliu-msft
Community Support
Community Support

Hi @KhurramJamshed ,

Do you want the sum of one field changes when textinput change?

Is Year 1' a fieldname?

If so, let me firstly explain why this only change you patch the changes:
Sum(ProjectGallery.AllItems,Value('Year 1'))  will calculate the sum of Year 1' field in data source.

Since you have not patched the changes, the year1 value in data source has not changed.

 

If you want to change before you patch, you need to make a little change, try this:
1)set the textinput's OnChange:

Set(var1,ThisItem.'Year 1');
Set(var2,textinputname.Text)

2)set the sum label's Text:

Sum(ProjectGallery.AllItems,Value('Year 1'))-Value(var1)+Value(var2)

Then you will minutes this record's original year1 value and plus the new data that you entered in .

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Yup, thank you for this! Not OP but had this same issue and the Patch() just would not show the updated values after the patch and was causing an issue but Sum() of the label in the gallery worked perfectly!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,606)