Split (split)
Description
Splits a string by a given literal separator and returns only the selected piece (counting from 0).
How does it work in the search window?
Select Create column in the search window toolbar, then select the Split operation. You need to specify three arguments:
Argument | Data type |
---|---|
Split mandatory | string |
by separator mandatory | string |
and return piece mandatory | integer |
The data type of the values in the new column is string.
Example
In the demo.ecommerce.data
table, we want to create a new column to show only the hour value in each string of the timestamp column. We need to get the part of the string that comes between the first and second : occurence. Using the : value as separator, each timestamp value will be split into 4 different pieces. For example, in the 24/Jun/2019:07:25:52 +0000 value, we need to get only the second piece. To do it, we will create a new column using the Split operation.
The arguments needed to create the new column are:
Split - timestamp column
by separator - Click the pencil icon and enter :
and return piece - Click the pencil icon and enter 1 (remember the count starts as 0, so you must enter 1 to get the second piece)
Click Create column and you will see the following result:
How does it work in LINQ?
Use the operator select
... as
... and add the operation syntax to create the new column. This is the syntax for the Split operation:
split(string, separator_string, piece_integer)
Example
You can copy the following LINQ script and try the above example on the demo.ecommerce.data
table.Â
from demo.ecommerce.data
select split(timestamp, ":", 1) as urscol1