Вопрос

I have a SharePoint list with a field, Field A, holding values such as "Text-11" or "DifferentText-150" and I want a new calculated field, Field B, that only shows the numeric part of Field A (i.e. "11", "150"). The number can be between 1 and 9999 so I can´t take always the last 2 digits.

Does anyone have an idea how to realize that with the calculated field function of SharePoint?

Это было полезно?

Решение

You will need to use several different functions to accomplish this. Your primary function will be MID which will allow you to grab a part of the original text but then you will also need to use SEARCH for your starting point and LEN to get the correct number of characters. Here are the steps for making your formula:

  1. You will need the index of the first character in the number. This can be achieved by finding the first character after the dash ('-'). Remember that indexes in SharePoint calculated fields start at 1 and not 0.

    SEARCH("-",[Title],1)

  2. Next you need to get the length of the number part of your string. This can be achieved by getting the length of the whole string and subtracting the index of the dash ('-').

    LEN([Title]) - SEARCH("-",[Title],1)

  3. Finally you can get the number part of the string by using the MID function and passing in the index of the first character in the number (Part 1) and the length of the number part (Part 2).

    MID([Title],SEARCH("-",[Title],1) + 1,LEN([Title]) - SEARCH("-",[Title],1))

Note: Title is just the name of the test column that I used.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top