Get distinct value and add few columns value

Hi I do have a question if I am applying distinct on certain columns, so it is printing only those column
I want it should be same and the format also should be same, only it should done the distinct part and all the remaining columns and format should remain same

Could you please advise

@Chirag1991

Try below expression.

Let’s say your input data is InputDT

OutputDT = (From row in InputDT Group row by a = row("ColumnName") into grp = Group Where grp.Count > 1 Select grp.First ).CopyToDataTable

I do have multiple column not one and what that 1 stand for

the expresiion which you have provided for that we have to use for each loop, any other way without loop

@Chirag1991

Separate the columns with comma and it should be some thing like this.

OutputDT = (From row in InputDT Group row by a = row(“ColumnName”), b = row(“ColumnName”) into grp = Group Where grp.Count > 1 Select grp.First ).CopyToDataTable

It will check multiple rows items found or not based on the condition.

@Chirag1991

It’s LINQ query but not loop.

Use Assign activity and write OutputDT on left hand side and remaining expression after equal sign into right hand side.

Hi I tried but I am getting error


Please see the screen shot

@Chirag1991

Remove dot . before Where and then check it once.


Still the error coming I attached the sceren shot

Format can be maintained the same with PreserveFormat option in READ RANGE activity itself

And for distinct column values use a DefautView method

dt = dt.DefaultView.ToTable(TRUE, “columnname-1”, “columnname-2”, … , “columnname-N”)

You can also pass the columnname as array like this

dt = dt.DefaultView.ToTable(TRUE, arrayvariable of column names)

Cheers @Chirag1991

I rectifed it thanks and its working

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