Compiler error processing expression

Hi everyone

I have a variable with the value to save =

DT_file5_data.AsEnumerable.Skip(2).
Where(Function(x) (If(DT_file5_data.Columns.Contains(“SHIPNAME”), Not String.IsNullOrEmpty(x(“SHIPNAME”).ToString), False)) AndAlso (If(DT_file5_data.Columns.Contains(“IMO”), Not String.IsNullOrEmpty(x(“IMO”).ToString), False)) AndAlso (If(DT_file5_data.Columns.Contains(“ME1.NOX”), Not String.IsNullOrEmpty(x(“ME1.NOX”).ToString), False)) AndAlso (If(DT_file5_data.Columns.Contains(“ME1.POWER”), Not String.IsNullOrEmpty(x(“ME1.POWER”).ToString), False)) AndAlso (If(DT_file5_data.Columns.Contains(“ME1.RPM”), Not String.IsNullOrEmpty(x(“ME1.RPM”).ToString), False)) AndAlso (If(DT_file5_data.Columns.Contains(“ME1.SFOC”), Not String.IsNullOrEmpty(x(“ME1.SFOC”).ToString), False))).
Select(Function(x)
’ Retrieve the year value and convert it to an integer if it’s not null or empty
Dim yearValue As Integer = If(DT_file5_data.Columns.Contains(“YEAR”) AndAlso Not String.IsNullOrEmpty(x(“YEAR”).ToString), CInt(x(“YEAR”).ToString), 0)

' Determine the new column value based on the year
Dim tierValue As String = If(yearValue < 2011, "T-I", If(yearValue >= 2011 AndAlso yearValue < 2016, "T-II", "T-III"))

DT_File5_Output.Rows.Add(
    If(DT_file5_data.Columns.Contains("SHIPNAME"), x("SHIPNAME").ToString, Nothing),
	If(DT_file5_data.Columns.Contains("IMO"), x("IMO").ToString, Nothing),
	"ME", "ME1", Nothing,
    If(DT_file5_data.Columns.Contains("ME1.NOX"), x("ME1.NOX").ToString, Nothing),
    If(DT_file5_data.Columns.Contains("ME1.POWER"), x("ME1.POWER").ToString, Nothing),
    If(DT_file5_data.Columns.Contains("ME1.RPM"), x("ME1.RPM").ToString, Nothing),
    "0.8", "1.1", "0.91", "0.95",
    If(DT_file5_data.Columns.Contains("ME1.TYPE"), x("ME1.TYPE").ToString, Nothing),
    If(DT_file5_data.Columns.Contains("YEAR"), x("YEAR").ToString, Nothing), 
	tierValue, Nothing, Nothing,
    If(DT_file5_data.Columns.Contains("ME1.SFOC"), x("ME1.SFOC").ToString, Nothing)
)

).ToList.ToArray

But it is giving me a compiler error expression as per below s/s:

Please assist, I am not sure what I did wrong here.
How do I properly write the expression ya?

we would recommend to rewrite the linq to a more readable manner and avoiding deep nested if clauses. Above initial coding strategy also looks a little bit like over-LINQed

A starter help for simplifcation could go into direction like

(From d in DT_file5_data.AsEnumerable.Skip(2)
Let colsetreq = {"SHIPNAME","IMO","ME1.NOX","ME1.POWER","ME1.RPM","ME1.SFOC"}
Let colset = d.itemArray.Select(Function (x,i) d.Table.Columns(i).ColumnName)
Let colcheck1 = colsetreq.Except(colset).Any()
Where not colcheck1 
Let valcheck = colset.Any(Function (x) isNothing(d(x)) OrElse Strig.IsNullOrEmpty(d(x).toString.Trim))
Where not valcheck
Select .....

we just filtered out when rows are missing needed columns or has missing blanks

Kindly note: it is a starter help and not a full implementation.

[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

My LINQ works fine before I add below “Dim” expression:

I needed to add them because I need to do an IF condition on the column “YEAR”. How do I add this properly in the expression?

still we recommend to avoid over-LINQing as it can be managed different and more optimizied as mentioned above

have a look at the Let clause from the query syntax

(From d in DT_file5_data.AsEnumerable.Skip(2)
Let colsetreq = {"SHIPNAME","IMO","ME1.NOX","ME1.POWER","ME1.RPM","ME1.SFOC"}
Let colset = d.itemArray.Select(Function (x,i) d.Table.Columns(i).ColumnName)
Let colcheck1 = colsetreq.Except(colset).Any()
Where not colcheck1 
Let valcheck = colset.Any(Function (x) isNothing(d(x)) OrElse Strig.IsNullOrEmpty(d(x).toString.Trim))
Where not valcheck
Let yearValue  = If(DT_file5_data.Columns.Contains("YEAR") AndAlso Not String.IsNullOrEmpty(x("YEAR").ToString), CInt(x("YEAR").ToString), 0)
Let tierValue = If(yearValue < 2011, "T-I", If(yearValue >= 2011 AndAlso yearValue < 2016, "T-II", "T-III"))
Let ra = Construct_Your_ItemArray_here
Select r = DT_File5_Output.Rows.Add(ra)).ToArray()

take as a starter help and keep in mind that we still can improve and optimize it to a more condensed and readable form