Not to remove leading zeros from datatable value

Hello everyone,

Need help ob below scenario

scenario
i have a datatable with below values, i want to get Max value from the data without trimming leading zeros

Dt1
Column1
0230
0560
0444
0654
0222

output expected
0654

Can anyone please help with this

Thanks in Advance

Hi @M1288

Try this:

Assign activity:
MaxValue = Dt1.AsEnumerable().Max(Function(row) row.Field(Of String)("Column1"))

Hope it helps

Hi @M1288

How about the following?

dtVar.AsEnumerable().Max(Function(r) r("Column1")).ToString()

Regards!

We can use the LINQ Max Operator:

But will have to convert the column value into a number e.g. CInt, CDbl…

Getting back the 4 length number we can use one of the options:
grafik

Hi @M1288

Check out the below image:

Hope it helps!!

Hi @Parvathy ,
Thanks for the response its working fine if all the data is having 4 digits but i have one… 3 digit number its returning 3 digit number instead of 4 digit value which ja actually Max value.

Whats happening?
Dt1
Column1
0179
0288
099
0287

Expected result
0288

But getting 099 as result.

can you please help on this.

As mentioned, we do need the numerical conversion
grafik

otherwise it would use the max from <T> Type and for string it risks the wrong lexically ratings
grafik

@M1288

Try this:

Assign activity:
MaxValue = Dt1.AsEnumerable().Max(Function(row) row.Field(Of String)("Column1").PadLeft(4, "0"c))

Hope it helps

Hi @M1288

According to both the examples of the data table provided this will be your output:

Hope it helps!!