Forum Discussion

jamiew23's avatar
jamiew23
Copper Contributor
Sep 02, 2021

Removing full stops from a number sequence

Hi all,

 

We have a single line text column that we use to ID folders. The ID's follow this structure 1.1.2.1.2

 

Is there a way a calculated field can take this sequence and remove the full stops between the numbers so instead of 1.1.2.1.2 we get a calculated column that returns 11212?

 

Thanks!

  • RobElliott's avatar
    RobElliott
    Silver Contributor

    jamiew23 one way to do this is to build a flow in Power Automate to strip out the dots and update the list with the result. In my example the original column (single line of text) with the folder name with dots is called Folder and the result without the dots (also single of text) is called Result.

     

    In your List Settings you MUST make sure that Item Version History is switched on as we will be comparing the current version of the item with the previous version. The flow will fail if you don't turn this on.

     

    In Power Automate the trigger is the SharePoint "when an item or a file is modified":

     

     

    The first action is "get changes for an item or a file (properties only). Select the ID from the dynamic content box on the right when you click in the ID field. For the Since field this is where we will look at the current and previous versions so add an expression of

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

     

    Next, initialize a string variable and in the Value field select the column with your current folder text, in my case that's called Folder:

     Next, add a Condition and select the Has column changed: Folder and set it to is equal to true

     

    In the red if no channel just leave it empty as we don't want anything to happen in the case. In the green if yes channel add a compose action and add the following expression which replaces the dots in the variable with  nothing:

     

    replace(variables('varReplace'),'.','')

     

     Finally, update the list item with the output of the compose action:

     This is the result. You should note that it can take 20-30 seconds for the flow to complete and update the list item:

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User

     

     

     

     

     

     

    • jamiew23's avatar
      jamiew23
      Copper Contributor
      Thank you for this I'll take a look.
      I've found that this code takes off the first dot in a sequence but doesn't remove the others. Is there any way I can manipulate this code to remove the other dots?

      =REPLACE(NumberColumn,SEARCH(".",NumberColumn),"1",""),

Resources