cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RoyDsouza
Helper I
Helper I

Increment a column value by +1 when a new submit occurs

Hello Experts,

I have tried searching for a solution in the history of the Power automate community posts , but could not find one matching my query. So here goes : 

 

Description: I have a registration form created in power apps integrated with 2 sharepoint lists. As i am not using Forms within the app,  the submit button uses a Patch function to patch the data into the SP list. 

The first part of the form is Event details (SP list 1) containing a fixed number of event topics etc. and the second is the Registration details (SP list 2) which contains participant information. 

 

Output of Power app: On submit a new record is created in SP list 2 - i.e registration information of the participant

RequirementOn submit - A column in the SP list 1 "No. of registered participants" must increment to +1 for that event and date chosen. The column type is a number and has a default value of 0 on record creation. 

My flow is :

RoyDsouza_0-1629897867422.png

 

 The compose function: 

if(equals(item()?['No_x002e_ofregisteredparticipant'], 0),1,add(item()?['No_x002e_ofregisteredparticipant'],1))
 

Problem: The flows runs successfully with output of condition as "False" and no increment takes place.

 

I have also considered keeping the default value of the SP column as blank/null and changed the IF formula to:

if(equals(item()?['No_x002e_ofregisteredparticipant'], null),1,add(item()?['No_x002e_ofregisteredparticipant'],1)) 

but this doesn't work as well.

Being a newbie to Power automate i do not know many functions.

Any leads and suggestions in this regard??

Can this be resolved with a patch function itself?

 

Thank you in advance.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @RoyDsouza,

 

If it is already a number 0 you shouldn't have to check for null. As far as I am aware the add function should be able to handle that. So, you should always be able to add 1, even with 0.

 

Can you try and use this expression in the update item action:

add(items('Apply_to_each')?['No_x002e_ofregisteredparticipant'], 1)

 

directlyupdateitem.png

View solution in original post

3 REPLIES 3
Expiscornovus
Super User
Super User

Hi @RoyDsouza,

 

If it is already a number 0 you shouldn't have to check for null. As far as I am aware the add function should be able to handle that. So, you should always be able to add 1, even with 0.

 

Can you try and use this expression in the update item action:

add(items('Apply_to_each')?['No_x002e_ofregisteredparticipant'], 1)

 

directlyupdateitem.png

RoyDsouza
Helper I
Helper I

Hi @Expiscornovus , 

Awesome. Thank you so much. That syntax worked, i was complicating stuff unnecessarily. 

However, i am just curious to know: If the column had no default value - I had to check for Null I believe and would the formula with Null hold good ?

 

Expiscornovus
Super User
Super User

Hi @RoyDsouza,

 

Yes, in that case I would check if it is empty. I would use an empty function for that btw.

 

add(if(empty(items('Apply_to_each')?['NullNumber']), 0, items('Apply_to_each')?['NullNumber']), 1)

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,234)