web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to subtract with F...
Power Apps
Unanswered

How to subtract with Forall

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

When I do a forall with a sum to add 1 to each value, it works perfectly.

Set(var_hours,ForAll(CollectHours,Sum(Value,1)))

 

But if I do -1 to subtract, I am getting an error.

Set(var_hours,ForAll(CollectHours,Sum(Value,-1)))

 

I can't find if there is an actual subtract function?

 

How do you subtract using the forall function?

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    152,872 Most Valuable Professional on at

    Hi @lardo5150 ,

    Just move the bracket

    Set(
     var_hours,
     ForAll(
     CollectHours,
     Sum(Value)-1
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • lardo5150 Profile Picture
    Microsoft Employee on at

    @WarrenBelz , sorry, I should have put the full formula.

    If(CurrentTimeZone.Text = "UTC-7:00",Set(var_hours,ForAll(CollectHours,Sum(Value)-1)));

    I am still getting an error with this.

    The formula contains 'ParenClose' where 'Eof' is expected

     

    Again, the same one works for adding a 1.

    If(CurrentTimeZone.Text = "UTC-6:00",Set(var_hours,ForAll(CollectHours,Sum(Value,1))));

    That -1 seems to be giving me trouble.

  • lardo5150 Profile Picture
    Microsoft Employee on at

    ok, it is not the formula.  Playing around I found this.

    I made the subtract formula first and it took.

    I then added my others, and the little red squiggly showed up on a different formula that was working before.

    So here is what I have.  I must be doing something wrong.

    lardo5150_0-1643496674131.pnglardo5150_1-1643496707885.png

     

    So essentially what I want to happen...

    I get the current time zone of the user, which I have validated works.

    I then run some if statements.  The one that matches gets set.

    What am I doing wrong here?

    If I use two of the formlas, it works.  when I add the third (and I still have to do pacific) it breaks.

  • lardo5150 Profile Picture
    Microsoft Employee on at

    I dont understand the error yet, but I think I fixed it.

     

    If(CurrentTimeZone.Text = "UTC-8:00",Set(var_hours,ForAll(CollectHours,Sum(Value)-2)));
    If(CurrentTimeZone.Text = "UTC-7:00",Set(var_hours,ForAll(CollectHours,Sum(Value)-1)));
    If(CurrentTimeZone.Text = "UTC-6:00",Set(var_hours,ForAll(CollectHours,Sum(Value,1))));
    If(CurrentTimeZone.Text = "UTC-5:00",Set(var_hours,ForAll(CollectHours,Sum(Value,0))));

  • WarrenBelz Profile Picture
    152,872 Most Valuable Professional on at

    Hi @lardo5150 ,

    I have just run the below on a test list I have here adding a numeric field and received the expected result

    If(
     User().Email = "xxxxxxx@xxxxxx.com",
     Set(
     var_hours,
     ForAll(
     TestFields,
     Sum(NumberTest) - 1
     )
     )
    )

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 759 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 228

Last 30 days Overall leaderboard