Auto-generate increment number based on specific column

Copper Contributor

For example,

if the user edits the column "A", then the column "B" will generate the number "1". (first time)

For the second time the user edits the column "A" again, the column "B" will increase to 2.

Can we set the column to auto-generate increment number based on a specific column?

 

 

 

 

1 Reply

@mmchx to do this you'll need a flow in Power Automate. You must turn on versioning in your list settings for this flow to work.

 

In my example whenever the Department column is changed the Inc column increments by 1.

 

The trigger is "When an item or file is modified". Next I've added a Compose action to get the current value of the Inc column. In the list a number column is saved as a flot but we need it as an integer so we convert it and the expression you add into the dynamic content box is 
int(triggerOutputs()?['body/Inc'])

 

Next we add an initialize variable action and set its initial value to the output of the previous compose.

1-Flow.png

 Next, add a "Get changes for an item or a file (properties only)" action, and because we want the changes since the previous version add the following expression into the Since field:

sub(int(triggerOutputs()?['body/{VersionNumber}']),1)

 

2-Flow.png

 

 Next we need to check if it was the Department column that had changed, so we add a Condition and select Has Column Changed: Department is equal to true

3-Flow.png

 

If it isn't that column but another one then we don't want to do anything, so the red if no channel can stay empty. But if the Department column has changed we want to add 1 to the Inc column. So in the green if yes channel add an increment variable action, select the variable you initialized earlier and set it to increment that variable by 1.

 

Finally, update the item in the list selecting the variable (with its new value) for the Inc column.

 

4-Flow.png

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User