# Excel , data

**URL:** <https://forum.uipath.com/t/excel-data/5700026>\
**Category:** Process Mining\
**Tags:** question, excel, system, activities\
**Created:** [December 18, 2025, 12:48pm UTC](https://forum.uipath.com/t/excel-data/5700026 "2025-12-18T12:48:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![nkaizer](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nkaizer/32/512855_2.png) [@nkaizer](https://forum.uipath.com/u/nkaizer)\
**Post date:** [December 18, 2025, 12:48pm UTC](https://forum.uipath.com/t/excel-data/5700026/1 "2025-12-18T12:48:10Z")

</div>

i have an Excel sheet that contains product codes, dates, and quantities, where some product codes appear more than once. I want to create a new table in which each product code appears only once, keeping the oldest date associated with that code and the corresponding quantity. If the same product code appears multiple times with the exact same date, the quantities should be summed and the total quantity should be stored. If the same product code appears with a more recent date compared to the oldest one, that record should be ignored. I have been trying to achieve this in different ways for the past two days without success. Can someone help me? thank you

---

<div class="post-metadata">

**Author:** ![ashokkarale](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashokkarale/32/474400_2.png) [@ashokkarale](https://forum.uipath.com/u/ashokkarale)\
**Post date:** [December 18, 2025, 1:04pm UTC](https://forum.uipath.com/t/excel-data/5700026/2 "2025-12-18T13:04:12Z")

</div>

@nkaizer

Share some sample input and output. Also what approach you tried and the issue you are facing.

---

<div class="post-metadata">

**Author:** ![MohammedShabbir](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mohammedshabbir/32/558335_2.png) [@MohammedShabbir](https://forum.uipath.com/u/MohammedShabbir)\
**Post date:** [December 18, 2025, 1:06pm UTC](https://forum.uipath.com/t/excel-data/5700026/3 "2025-12-18T13:06:36Z")

</div>

You can do it with ease in UiPath using linq.

Can you share a sample or some screenshot’s, so that we can have a clarity.

---

<div class="post-metadata">

**Author:** ![nkaizer](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nkaizer/32/512855_2.png) [@nkaizer](https://forum.uipath.com/u/nkaizer)\
**Post date:** [December 18, 2025, 1:12pm UTC](https://forum.uipath.com/t/excel-data/5700026/4 "2025-12-18T13:12:35Z")

</div>

I tried using Read Range to get the Excel table, then a For Each Row loop to iterate through all rows. Inside the loop, I used If activities to check valid dates and whether the code already exists in a dictionary. I used assign activities to store the oldest date and update quantities if the same date appears, and Add Data Row to populate the result DataTable. Finally, I wrote the output with Write Range. Despite this, the results were not correct.

---

<div class="post-metadata">

**Author:** ![nkaizer](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nkaizer/32/512855_2.png) [@nkaizer](https://forum.uipath.com/u/nkaizer)\
**Post date:** [December 18, 2025, 1:17pm UTC](https://forum.uipath.com/t/excel-data/5700026/5 "2025-12-18T13:17:28Z")

</div>

| Codes | Qty | Date |
| --- | --- | --- |
| 42230298 | 22 | 11/27/2025 |
| 33230288 | 3 | 12/12/2025 |
| 22230304 | 204 | 3/31/2026 |
| 82230297 | 11 | 3/31/2026 |
| 82230297 | 464 | 3/31/2026 |
| 72230299 | 94 | 5/28/2026 |
| 22290285 | 132 | 6/5/2026 |
| 24230287 | 31 | 6/5/2026 |
| 33230288 | 50 | 6/5/2026 |
| 22230280 | 159 | 6/11/2026 |
| 42230298 | 320 | 7/7/2026 |

---

<div class="post-metadata">

**Author:** ![nkaizer](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nkaizer/32/512855_2.png) [@nkaizer](https://forum.uipath.com/u/nkaizer)\
**Post date:** [December 18, 2025, 1:24pm UTC](https://forum.uipath.com/t/excel-data/5700026/6 "2025-12-18T13:24:48Z")

</div>

My result looks like this, but it is incorrect (the dates are wrong and the codes are repeated multiple times):  
01/01/01-132  
01/01/01-159  
01/01/01-132  
01/01/01-159  
01/01/01-31

---

<div class="post-metadata">

**Author:** ![Maheep\_Tiwari](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/maheep_tiwari/32/399521_2.png) [@Maheep\_Tiwari](https://forum.uipath.com/u/Maheep_Tiwari)\
**Post date:** [December 18, 2025, 1:28pm UTC](https://forum.uipath.com/t/excel-data/5700026/7 "2025-12-18T13:28:52Z")

</div>

Try this,

1. Read Range  
Read Excel into dtInput
2. Assign (LINQ only, no Rows.Add inside it)  
Create a new DataTable from LINQ properly.

Assign → dtResult = (  
From r In dtInput.AsEnumerable()  
Group r By code = r(“Codes”).ToString() Into grp = Group  
Let minDate = grp.Min(Function(x) CDate(x(“Date”)))  
Select New Object() {  
code,  
grp.Where(Function(x) CDate(x(“Date”)) = minDate).  
Sum(Function(x) CInt(x(“Qty”))),  
minDate  
}  
).ToList().  
Aggregate(  
dtInput.Clone(),  
Function(dt, x)  
dt.Rows.Add(x(0), x(1), x(2))  
Return dt  
End Function  
)  
3. Write Range  
Write dtResult once to Excel

---

<div class="post-metadata">

**Author:** ![nkaizer](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/nkaizer/32/512855_2.png) [@nkaizer](https://forum.uipath.com/u/nkaizer)\
**Post date:** [December 18, 2025, 2:41pm UTC](https://forum.uipath.com/t/excel-data/5700026/8 "2025-12-18T14:41:05Z")

</div>

i changed a bit the process because this for me doesn’t work . but i use the logic which was correct. thank you!!!

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [December 21, 2025, 2:41pm UTC](https://forum.uipath.com/t/excel-data/5700026/9 "2025-12-21T14:41:08Z")

</div>

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