Update last Row value in the first row for only duplicate value set

I have this CSV Data, I want to get Duplicate value from ID column and each duplicate value set want to update last row value to be inserted in the first row of duplicate set do it in every set one by one

Hi @Garyy

Can you provide the csv file if possible.

Hi @Garyy
Check out this

I hope it helps!!

Thank you for your response but this solution is different this is not what I’m looking

@Garyy

Try this

Create avariable str_id and initialize with string.Empty

  1. Use for each row in datatable on the data read from excel say dt
  2. Inside the loop use if condition with str_id.Equals(currentRow("ID").ToString)
  3. On the then side do nothing
  4. On else side use assign with str_id = currentRow("ID").ToString
  5. On the else side after assign use filter datatable actovity and filter dt and output can be filtereddt…and filter "ID" equals currentRow("ID").ToString
  6. Use another assign after filter with currentRow("1-DD").ToString = filtereddt.Rows(filtereddt.Rowcount-1)("1-DD").ToString

This will ensure every first new row is replaced with last row

Cheers

Can you send me the xaml code

@Garyy

This is how it looks

NewTry.xaml (11.6 KB)

cheers

Thank You @Anil_G
But shy getting this error

@Garyy

Please check in the multiple assign if filtereddt.Rowcount-1 is given or not

cheers

Thanks @Anil_G
I have one more doubt i take only one column “1-DD” but if i want column name start with “DD-”
how can do it
And another one if last row is empty or null then get above row value and put it in first row
Please help me

@Garyy

Inside the first loop …use a loop for the columns and check the column names that starts or ends with DD as you need or contains DD…the second loop will be on dt.Columns and type argument in loop will be DataColumn

And the if condition goes inside the second loop and instead of 1-DD use currentItem.ColumnName

And also for last but second…you need to include one more if condition before the multiple assign so that you can check the value is empty and choose last second row instead of last

Cheers

Ok I will try it

@Garyy

Sending a xaml is not a problem…but if you try there is possibility you will learn as well…give me some time.:not in front of system will send it…

But will suggest try to amend the changes…for better learning

Cheers

I tried but i didn’t get output what i am looking

@Garyy

Please check this

this is how the second for is to be used

NewTry.xaml (18.4 KB)

cheers

Why getting this error
Multiple Assign: Can not assign ‘filtereddt.Rows(filtereddt.RowCount-2)(currentItem.ColumnName)’ to ‘CurrentRow(currentItem.ColumnName)’.

@Garyy
Verify that the data types of filtereddt.Rows(filtereddt.RowCount-2)(currentItem.ColumnName) and CurrentRow(currentItem.ColumnName) match. If they don’t, you may need to convert the data types or adjust.

Hope it helps!!

@Garyy

Please use separate assigns or open the exception details from locals panel to check the exact error

mostly you would need to check the values in datatable if it has two rows or not…may be there is no second last row and last row is empty

cheers

Yes right from second last row has no value, I want to value from which has value In that scenario which row has value some time it come last row or second last row or third last row so that scenario which logic is working

@Garyy

Then remove the if condition to check for Empty and use -1 or -2 instead in the filter datatable activity include one more filter with currentItem.ColumnName IsNotEmpty

This will filter the blanks also and last non blank will be retrieved using filteredfdt.rowcount-1

if all rows also will be blank is a condition then first check if filteredrowcount>0 then perform the assign

cheers