How to get the minimum amount of a datatable colomn and the line associated to it

Hello Friend,

I have the Following datatable:

numeroCredit,taux,resteAVerser,nomProduit
713148E,2.61,100,PRET HABITAT PRIMO
713149E,2.78,17676.95,PRET HABITAT PRIMOLIS 2 PALIERS

i have to get the values of the line where the column is the Minimum one

Hi @abdel

1. Assign:
   - Integer: minResteAVerser = Int32.MaxValue
   - DataRow: rowWithMinValue = Nothing

2. For Each Row:
   - Input: DataTable (your input DataTable)
   - Output: row (of type DataRow)

3. If (Condition):
   - Condition: Convert.ToInt32(row("resteAVerser")) < minResteAVerser
   - This condition checks if the current row's "resteAVerser" value is smaller than the minimum value.

4. Assign (inside the "Then" block):
   - To: minResteAVerser
   - Value: Convert.ToInt32(row("resteAVerser"))

5. Assign (inside the "Then" block):
   - To: rowWithMinValue
   - Value: row

6. End If

7. End For Each

8. Output (Print the result):
   - Use a Message Box activity (or any other activity) to display the row with the minimum value.
   - Text: rowWithMinValue.Item("numeroCredit").ToString + ", " +
           rowWithMinValue.Item("taux").ToString + ", " +
           rowWithMinValue.Item("resteAVerser").ToString + ", " +
           rowWithMinValue.Item("nomProduit").ToString

Assign Activity
minRow | DataType: DataRow =
YourDataTableVar.AsEnumerable().OrderBy(Function (x) CDbl(x(“taux”).toString.Trim)).First()

Then you can use minRow(ColNameOrIndex) and access all other column values

Hi @abdel

Use the linq expression to get the minimum value in a column of datatable.

minValue = dtData.AsEnumerable().Min(Function(row) row.Field(Of YourDataType)("ColumnName"))

Create a minValue variable, In YourDataType give the datatype of Column and In ColumnName give the Column name that you want to get the minimum value.

Hope it helps!!