Consolidating datarows

Hello -

I have a DT that looks like this:

Col1 Col 2
Value1 ValueA
Value1 ValueA
Value1 ValueB
Value2 ValueA

I essentially need to consolidate unnecessary rows and count the rows I do consolidate.

With the above example, I need to invoke Sample1.xaml once for each unique value in Col1 (in this case, invoke for Value1 and for Value2).

Then, I need to invoke Sample2.xaml for each unique pairing of Col1 and Col2 (in this case, invoke for Value1:ValueA *2, for Value1:ValueB *1, and for Value2:ValueA *1) and pass the number of occurrences of each pairing (the asterisk number).

Hopefully that’s clear enough. Any help is greatly appreciated!

hi

You can eliminate duplication by using the DataView.ToTable method.

Execute with assign activity:
newDt = dt.DefaultView.ToTable(true, {“Col1”, “Col2”})

1 Like

Thanks!

Is there any way to count the number of rows that are being consolidated? I think I could use a For Each that searches against the original DT to count, but is there a better way?

Thanks!

You can get the number of rows in DataTable with newDt.Rows.Count

Is there a way to count how many rows were consolidated though?

Example:

DT
Col 1
Value1
Value1
Value1
Value2
Value2

NewDT
Col1
Value1
Value2

I want to know that Value1 occurred three times and Value2 occurred two times.

Thanks!

The number of Value 1 can be obtained by the following processing.

dt.Select ("Col1 = ‘Value1’ '). Length

@kawata.isao i given same statement but i am not getting value. Can u please check it.Main.xaml (7.8 KB)

Is it such an image?

output:
image

Main_mod.xaml (9.3 KB)