cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sobenson
Helper II
Helper II

Subtract from SharePoint column unless greater than 0

I am writing a flow that if someone changes a "status" column a second "priority" column will subtract 1 from the current value.  I am using the expression:

sub(outputs('Update_item_2')?['body/on0o'],1)

and it works, however I don't want to to go below zero.

I tried this, but it says my expression is invalid

if(triggerOutputs()?['body/on0o']>0,(sub(triggerOutputs()?['body/on0o'],1)),)

Any suggestions?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paulie78
Super User
Super User

 

if
(
  greater(variables('number'),0), sub(variables('number'),1), 0
)

 

See how you get on with that instead, I think your exact expression would be:

if
(
  greater(triggerOutputs()?['body/on0o'],0),(sub(triggerOutputs()?['body/on0o'],1)),0
)

But you will have to check your end.

 

Please...

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

View solution in original post

2 REPLIES 2
Paulie78
Super User
Super User

 

if
(
  greater(variables('number'),0), sub(variables('number'),1), 0
)

 

See how you get on with that instead, I think your exact expression would be:

if
(
  greater(triggerOutputs()?['body/on0o'],0),(sub(triggerOutputs()?['body/on0o'],1)),0
)

But you will have to check your end.

 

Please...

If I answered your question Accept it as a solution ✔️ 

If I helped you out, please give me some Kudos 👍

Thanks 😙

Hi @Paulie78 , thank you! 

You had one to many () in the sub statement in the example you copied of my info, (your example statement was correct) but this worked great!  Thanks!

 

This was the final working version

if(greater(triggerOutputs()?['body/on0o'],0),sub(triggerOutputs()?['body/on0o'],1),0)

 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (2,474)