42
Views
13
Comments
Solved
How to Remove Duplicates While Exporting List to Excel Using Advanced Excel Component
Question

Hi everyone,

I have a list in my Outsystems app that may contain duplicate records, and this is intentional—I want to display and manage them in the UI as-is. However, when I click the Download button to export this list to an Excel file (using the Advanced Excel Forge component), I need to exclude the duplicates from the Excel file.

Is there a way to remove duplicates only during the export process, without affecting the list data shown on the screen?

I'm looking for a clean and efficient approach to handle this in a server action before generating the Excel.

Any help, logic suggestion, or sample would be appreciated!

Also I am attaching my OML File, Just go through the file.

Thanks in advance.

Advance_Excel_T.oml
2025-05-02 20-28-47
Drishti Menghani
Solution

Hi Sagar,

You can probably use ListDistinct just before the iteration, it will list out all the unique combinations your aggregate is having. 


If you strictly want to use Advance Excel, then you should use Formula action just like below. It's excel formula which will be applied based on the row and column even when you applied to single cell it will be applied to the range you would select which is described below, please give it a try.

In the below it just explains that (=UNIQUE Records only which lies between A1 i.e., First Coloum, Fist Row and E10, 5th Coloum and 10th Row) make sure to change the E10  dynamically based on your number of rows. I haven't tried but give it a try, it should work.


Let's me know if you really want me to give it a try.

2025-10-09 13-52-02
Sagar Andyal

Hi @Drishti Menghani ,

I am Also trying both ways, Ill Used ListDistinct But is storing only one record.

And also Tried Cell_SetFormulaByIndex but I cant get proper result.

Could you please try for me.


2016-04-22 00-29-45
Nuno Reis
 
MVP

Hello.


A simple solution would be to store in a temporary SQL table.

If they have IDs, the insert ou update would remove the duplicates, then you just export.

If they don't have Ids, export with distinct and that's it.


If it is for a single user, don't forget to truncate the table after each use.

If multiple users can call it, you have to log the request, mark each record as a child of that request, and also clear at the end.

2025-10-09 13-52-02
Sagar Andyal

Hi @Nuno Reis ,

Thanks a lot for your reply!

I'm still new to OutSystems, so I didn’t fully understand your explanation. Could you please explain it in a simpler way or maybe step-by-step? If you can show where to put the logic in Service Studio (like in Server Action or Aggregate), that would really help me understand better.

Thanks again for helping!

2016-04-22 00-29-45
Nuno Reis
 
MVP

Looking at your code, all you need is a Group By. I changed the Aggregate and corrected the Assigns.


Advance_Excel_T.oml
2025-10-09 13-52-02
Sagar Andyal

Without Group by isn't possible to complete this requirements using advance excel. 

2024-10-16 11-59-48
Nick Vandebriel

Hi Sagar,

You can get this with a group by. I also took a look at your code and in your case the advanced excel tool is not needed, you can use the built in recordlistToexcel. I put an example below. 



Advance_Excel_TRecordList.oml
2025-10-09 13-52-02
Sagar Andyal

Hi @Nick Vandebriel ,

Is it possible to achieve this requirement using the Advanced Excel component without using a Group By operation? 

2024-10-16 11-59-48
Nick Vandebriel

Hi Sagar,

You can take a look on the list distinct function. But is there a reason you don't want to use a group by?

2025-10-09 13-52-02
Sagar Andyal

Hi @Nick Vandebriel ,

I Used Group By, But I am Trying To achieve In Another Way, So for that I am Exploring Advance Excel.

Isn't Possible Using Advance Excel? 

2016-04-22 00-29-45
Nuno Reis
 
MVP

Do you see any action in Advance Excel for Remove Duplicates?

Your best option would be to load a table into Excel, use it as source for a pivot table, and do the same thing on Excel with two sheets, one of duplicate entries and one of single entries.

Do it on SQL that is the tool for it.

2025-10-09 13-52-02
Sagar Andyal

Hi @Nuno Reis ,

I Don't Know is there any action in Advance Excel ,

How to do that Using SQL Tool.

Could you please elaborate.


2016-04-22 00-29-45
Nuno Reis
 
MVP

That's my point. There is no action for it. Advanced Excel is to manipulate the format of output, not to generate the data.

You can do it in SQL, but you can also do it in an Aggregate like I explained yesterday. If you already have the ideal solution, why do things in a more complex way?


2025-05-02 20-28-47
Drishti Menghani
Solution

Hi Sagar,

You can probably use ListDistinct just before the iteration, it will list out all the unique combinations your aggregate is having. 


If you strictly want to use Advance Excel, then you should use Formula action just like below. It's excel formula which will be applied based on the row and column even when you applied to single cell it will be applied to the range you would select which is described below, please give it a try.

In the below it just explains that (=UNIQUE Records only which lies between A1 i.e., First Coloum, Fist Row and E10, 5th Coloum and 10th Row) make sure to change the E10  dynamically based on your number of rows. I haven't tried but give it a try, it should work.


Let's me know if you really want me to give it a try.

2025-10-09 13-52-02
Sagar Andyal

Hi @Drishti Menghani ,

I am Also trying both ways, Ill Used ListDistinct But is storing only one record.

And also Tried Cell_SetFormulaByIndex but I cant get proper result.

Could you please try for me.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.