M1288
(Meg1288)
December 11, 2023, 3:18pm
1
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
Parvathy
(PS Parvathy)
December 11, 2023, 3:21pm
2
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!
ppr
(Peter Preuss)
December 11, 2023, 3:26pm
4
We can use the LINQ Max Operator:
This HowTo gives an introductory overview of the aggregation Operators: Min, Max, Sum, Average
Introduction
The aggregation operators are used to retrieve from a collection a particular result by setting the contained items into a relationship.
Overview
I – Input
P – Processing
O – Output
{2,12,-8,6,14,5}
get the lowest value
-8
{2,12,-8,6,14,5}
get the highest value
14
{2,12,-8,6,14,5}
sum up all values
31
{2,12,-8,6,14,5}
get the average of all values
5.17
Constraints
Perf…
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:
Parvathy
(PS Parvathy)
December 11, 2023, 3:28pm
5
Hi @M1288
Check out the below image:
Hope it helps!!
M1288
(Meg1288)
December 11, 2023, 3:37pm
6
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.
ppr
(Peter Preuss)
December 11, 2023, 3:46pm
7
As mentioned, we do need the numerical conversion
otherwise it would use the max from <T> Type and for string it risks the wrong lexically ratings
Parvathy
(PS Parvathy)
December 11, 2023, 3:47pm
8
@M1288
Try this:
Assign activity:
MaxValue = Dt1.AsEnumerable().Max(Function(row) row.Field(Of String)("Column1").PadLeft(4, "0"c))
Hope it helps
Parvathy
(PS Parvathy)
December 11, 2023, 3:52pm
9
Hi @M1288
According to both the examples of the data table provided this will be your output:
Hope it helps!!