Need max value in the datatable

Hi i have this table i want only "Doc Type = “Authorization form completed” " and with the latest date

@katta_nikhil
Hi,

Thanks

no its not working… it is giving only if today date is there or not… if today date is not there … it is showing null

Hi @katta_nikhil

Use the below linq query

Output = YourDatatable.AsEnumerable().Max(Function(row) row.Field(Of DateTime)("DateColumn") and row.Field(Of Double)(“ValueColumn”))

The column have to change based on your datatable.

Hope it helps!!

bro i want doc type = “Authorization form completed” … in that doctype i need max value

Hi,

Try this

[YourDTVariable].AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString

@katta_nikhil

Use filterdatatable activity to filter Doc Type = “Authorization form completed"
and then store it in a filterdatatable.And then use linq query to get the max date

[YourDTVariable].AsEnumerable().Max(Function (drRows) DateTime.Parse(drRows.Item([YourColumnIndex/Name]).ToString)).ToString

Thanks

Hi @katta_nikhil

Try this:

  1. For latest date only:
    latestDate = YourDataTable.AsEnumerable().Where(Function(row) row.Field(Of String)("Doc Type") = "Authorization form completed").Max(Function(row) DateTime.Parse(row.Field(Of String)("Scan Date"))).ToString("MM-dd-yyyy")

  2. For latest row in datatable:
    filteredRows = YourDataTable.AsEnumerable().Where(Function(row) row.Field(Of String)("Doc Type") = "Authorization form completed").OrderByDescending(Function(row) DateTime.Parse(row.Field(Of String)("Scan Date"))).Take(1).CopyToDataTable()

This will give the latest date for Authorization form completed.

Regards,

Okay @katta_nikhil

@katta_nikhil Here is the linQ query, leave the last one and consider this one

Output = YourDataTable.AsEnumerable().Where(Function(row) row.Field(Of String)("Doc_Type")="Authorization form completed").Max(Function(row) row.Field(Of DateTime)("Scan_Date"))

Hope it helps!!

@katta_nikhil

Better would be use UI…I believe if you click on Scan date then everything will be ordered

then your task is to check for the first Authorization form completed which can be done using innertext in selector

cheers

first one is working but i want to consider with latest time also

But the time is not available in the datatable.