Get data against row value in excel using Linq

image

Need to Capture data against row value in Excel using Linq
Like in your given example I need to fetch
for 23/01 need 12/26/22 and 01/08/23
for 23/02 need 01/09/23 and 01/22/23
for 23/03 need 01/23/23 and 02/05/23
i.e. from and To value
Calender.xlsx (12.6 KB)

Any expert please?

@c3f1e68294fdcf4a1f0a817ca

you can easily do it using filter datatable rather than linq…as you need a single row

or even a look up table activity will also do the same

cheers

I have given examples of only few row but in actual it will have large set of data

@c3f1e68294fdcf4a1f0a817ca

Even then …filter will work…as you need only one…if you are looking to filter multiple rows and then use …linq makes sense…but each tiem you need only one

If you still need try this

Dt.AsEnumerable.Where(function(x) x(0).ToString.Equals("23/01"))(0)(1).ToString

This gives start and for end use 3 instead of 1

Cheers

thanks but getting below error

and yes you are right, I need value one by one

@c3f1e68294fdcf4a1f0a817ca

output of read Excel: dt_excel

build a datatble : dt_filter with desired 3 colums (Calander year,From,To)

dt_filter=dt_excel.AsEnumerable.Select(Function(x) dt_Filter.Clone.LoadDataRow({x(0).ToString,x(1).ToString,x(3).ToString},False)).copytodatatable

I don’t need a data table.
if I pass 23/01 then need 12/26/22 and 01/08/23.
I pass 23/02 then need 01/09/23 and 01/22/23
I pass 23/03 then need 01/23/23 and 02/05/23

@c3f1e68294fdcf4a1f0a817ca

Is dt a datatable?

As you need single values using lookup would be the best option considering readability as well

cheers

Hi @c3f1e68294fdcf4a1f0a817ca

Try this:

fromDate = Dt.AsEnumerable().Where(Function(row) row(0).ToString() = "23/01").Select(Function(row) row(1).ToString()).FirstOrDefault()
toDate = Dt.AsEnumerable().Where(Function(row) row(0).ToString() = "23/01").Select(Function(row) row(3).ToString()).FirstOrDefault()

Getting this error

BC30690: Structue ‘Char’ cannot be indexded because it has no default property.

How to use Data filter instead of linq? here dont know why but getting this error, any other way please

Getting same error


BC30690: Structue ‘Char’ cannot be indexded because it has no default property

How to use Data filter instead of linq? here dont know why but getting this error, any other way please

How to use Data filter instead of linq? here dont know why but getting this error, any other way please

@c3f1e68294fdcf4a1f0a817ca

try this

cheers

Hi @c3f1e68294fdcf4a1f0a817ca

You are getting that error because in the place of sheet name you are creating variable called dt, you are not giving the sheetname.

In the properties of Read Range activity you need to create a variable

Check on this xaml

BlankProcess12.zip (38.9 KB)

Hope this helps!!

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