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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

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
    153,779 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
    153,779 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 93 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
Valantis Profile Picture

Valantis 49

Last 30 days Overall leaderboard