Hello All, My excel file contains number of records with mixed status if there is any failed status i have to display one failed record and exclude the remaining records

I Have Record in excel file i have casenumbers and their status:

casenumber statusid Status
C31388906 3 Success
C31388906 3 Success
C31388906 4 Success
C31388906 3 Failed
i have to show only one record i mean if the casenumbers all are success i have to show only one success record if some records are failed i have to show only one failed record and have to remove the duplicate casenumbers and their status the output should be like the below:
casenumber statusid Status
— — —
C31388906 3 Failed
Can someone help me on this

Hi,

Can you try the following sample?

dtResult = dt.AsEnumerable.GroupBy(Function(r) r("casenumber").ToString).Select(Function(g) g.OrderBy(Function(r) keywordSuccess.Contains(r("Status").ToString)).First()).CopyToDataTable()

Sample20230125-6L.zip (2.9 KB)

Regards,

hi @Yoichi thanks for your repsonse
Actually my process was in C# while using the above expression:
resultdata.AsEnumerable.GroupBy(Function(r) r(“casenumber”).ToString()).Select(Function(g) g.OrderBy(Function(r) keywordSuccess.Contains(r(“Status”).ToString())).First()).CopyToDataTable()


image

Hi,

Can you try the following?

dtResult = dt.AsEnumerable().GroupBy(r=> r["casenumber"].ToString()).Select(g=>g.OrderBy(r=>keywordSuccess.Contains(r["Status"].ToString())).First()).CopyToDataTable()

Sample20230125-6LCS.zip (3.0 KB)

Regards,

@Yoichi Yes, i tried the expression in the above mentioned but facing the issue
image

Hi,

Can you share your current expression?

Regards,

resultdata.AsEnumerable.GroupBy(Function(r) r(“casenumber”).ToString).Select(Function(g) g.OrderBy(Function(r) Keyword.Contains(r(“Status”).ToString)).First()).CopyToDataTable()

where resultdata is my excel data output
Keyword is my “Success”

Hi,

Can you check the above attached sample : Sample20230125-6LCS.zip (3.0 KB)
It includes C# code.

Regards,

1 Like

@Yoichi thank you for the help it’s working fine

1 Like

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