Get Name which has minimum Marks

Get Name which has minimum Marks

Output : Jeff which has low 23 marks

The forum search feature is a useful tool.

Try this

Name=dataTable.AsEnumerable().OrderBy(Function(row) row.Field(Of Integer)("Marks")).FirstOrDefault()?("Name").ToString()

BC37240: A null propagating operator cannot be converted into an expression tree
Why getting this error


    OrderBy(Function(row) row.Field(Of Integer)("Marks")).FirstOrDefault()?.
    Field(Of String)("Name") ?? String.Empty

not working
BC37240: A null propagating operator cannot be converted into an expression tree.

If you want to avoid code and just use native activities:

  • Sort the table on column ‘Marks’ (Ascending)
  • Read Name in the 1st row (code: myDatatable.rows(0)(“Name”).toString )

last try

    .OrderBy(row => row.Field<int>("Marks"))
    .FirstOrDefault()?["Name"] ?? string.Empty;

Hi @Garyy
Try this
YourDT.AsEnumerable.Min(function(row) row(”Column name”).ToString)

This is ideal, but they’d have to convert “Marks” to integer first.

True (assuming it isn’t already ofc.).
I have yet to meet a Mark that likes to be called an integer… We may have a challenge there…

1 Like

Hi @Garyy

Use the read range workbook activity and store the output in a datatable variable.
Use the two assigns activities.

- Assign -> minValue = dt.AsEnumerable().Min(Function(row) Convert.ToDouble(row("Mark")))
- Assign -> minName = dt.AsEnumerable().Where(Function(row) Convert.ToDouble(row("Mark")) = minValue).Select(Function(row) row("Name").ToString).FirstOrDefault()
- Assign -> Result = minName+" which has low "+minValue+" marks"

Hope it helps!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.