Nested query to report two set of data using linq

Hi all,

I need your precious help to resolve the expression below intended to return two set of data based on 2 independant Equals.

I encounter an error of type: ‘Range variable name can not match the name of a member of the ‘Object’ class.’

can it be done in one go or do I have to do it in 2?

Thanks for your help.

(From row1 In Filtered_F.AsEnumerable
Join row2 In dt_Parametre2.AsEnumerable
On row1(“BANNIERE”).ToString Equals row2(“BANNIERE”).tostring
Let unitValue = row2(“Unit”).ToString
Let profitValue = row2(“Centre profit”).ToString
Let cptValue = (From row3 In Filtered_F.AsEnumerable
Join row4 In dt_Parametre2.AsEnumerable
On row3(“MDT_IMM_DIF”).tostring Equals row4(“MDT_IMM_DIF”).tostring
Select row3(“Compte Comptable”).ToString)
Let mappedValues = (From col In DT_Template_Fac.Columns.Cast(Of System.Data.DataColumn)
Let colName = col.ColumnName
Select If(colName = “Code Société”, unitValue,
If(colName = “Centre de profit”, profitValue,
If(colName = “Compte Comptable”, cptValue, Nothing)))
).ToArray()
Select DT_Template_Fac.LoadDataRow(mappedValues, True)
).CopyToDataTable()

@bloog

Please explain the requirement may be that would better give an idea on how to tackle this and help

Cheers

Hello Anil,

the goal is to complete a table that containing only headers (DT_Template_Fac) after joining two other tables (Filtered_F < = > dt_Parametre2).

i need to report 3 columns from this join:

  • 2 columns from dt_Parametre2 based on equals between ‘BANNIERE’ columns in the 2 tables (FIRST VLOOKUP)

  • 1 column from dt_Parametre2 based on equals between ‘MDT_IMM_DIF’ columns in the 2 tables (SECOND VLOOKUP)

I’d like to do this in 1 expression if possible.

Please don’t hesitate if it’s not clear. Thanks for your help :pray:

@bloog

Instead …if you need the joined columns only…simple way is to use filter datatable after join and select columns tab and keep only columns u need

Cheers

1 Like