Count character

I want to count character in column Create ID.

If count character= 7 insert 0 in front of old text.

Please guide me for solve it.
data.xlsx (10.2 KB)

You can use For Each Row activity, inside that you can access the Create ID column value as CurrentRow(“Create ID”).ToString, and get the character count inside that string using Length method

CurrentRow(“Create ID”).ToString.Length

1 Like

image
This is input file
and Below is the output
image
Count_Char.zip (41.7 KB)

1 Like

Hi,

Try below linq

Assign activity:
ResultDataTable = (From row In YourDataTableVar.AsEnumerable()
Let value = row.Field(Of String)(“ColumnA”)
Let newValue = If(value.Length = 7, “0” + value, value)
Select YourDataTableVar.Clone().Rows.Add({newValue}).CopyToDataTable()).CopyToDataTable()

@Jayesh_678

I have a question.

If I want to sort column Planned Start (ascending)
How to edit your code?

Thank you.

Hi @fairymemay

Try this:

ResultDataTable = (From row In YourDataTableVar.AsEnumerable()
                   Let value = row.Field(Of String)("ColumnA")
                   Let newValue = If(value.Length = 7, "0" + value, value)
                   Order By row.Field(Of DateTime)("Planned Start") Ascending
                   Select YourDataTableVar.Clone().Rows.Add({newValue}).CopyToDataTable()).CopyToDataTable()

Hope it helps!!

@parvathy Now I have error as below.

How to solve it?

Hi,

Here is the modified linq query:-

ResultDataTable = (From row In YourDataTableVar.AsEnumerable()
Let value = row.Field(Of String)(“ColumnA”)
Let newValue = If(value.Length = 7, “0” + value, value)
Select YourDataTableVar.Clone().Rows.Add({newValue})
Order By DateTime.ParseExact(row.Field(Of String)(“Planned start date”), “dd/MM/yyyy”, CultureInfo.InvariantCulture)
).CopyToDataTable()

Hi @fairymemay

Pass your datatable variable in place of YourDataTableVar.
Regards

@Jayesh_678 @Parvathy error as below.

Hi,

Import below dependencies from import tab

Imports System.Data
Imports System.Globalization

Thanks

Replace Column A with your Id column name , replace planned start date with your planned start date column. Column names are case sensitive.

Thanks

1 Like

Hi @fairymemay

What is your output variable DataType?

ResultDataTable = (From row In YourDataTableVar.AsEnumerable()
                   Let value = row.Field(Of String)("ColumnA")
                   Let newValue = If(value.Length = 7, "0" & value, value)
                   Order By DateTime.ParseExact(row.Field(Of String)("Planned Start"), "M/d/yyyy", System.Globalization.CultureInfo.InvariantCulture) Ascending
                   Select YourDataTableVar.Clone().Rows.Add({newValue}).CopyToDataTable()).CopyToDataTable()

Hope it helps!!

@parvarthy @Jayesh_678 error as below.

image

1 Like

Hi,

Give me some time. I will provide you a xaml file.

Thanks

1 Like

@Jayesh_678 if I want to more filter column Owner = IT or Eng.

How to edit code?

@Jayesh_678 @parvarthy Now error as below.

How to solve it?