Aggregate for +500 columns

Hello,
I hope you are all safe !

I have a question with the aggregate function.
I have a large file (+500 columns) that I need to aggregate “by product”

Exemple

and I need to have the Following output

How can I do this without having to tick all the columns one by one (as I did in my example)

Thanks for your help
Edward

Hi Edward and welcome to the Community!

You can unpivot all columns in the table except Produit, aggregate, and then pivot back.

See attached a sample project that does it. Notice that the project has 2 tabs - one with an example that doesn’t preserve the order of columns, and the other one that does.

many-column-aggregation.morph (6.1 KB)
Book1.xlsx (9.7 KB)

This approach can work for tables with any number of columns. However, keep in mind that unpivoting may produce a very long table. If you have 500 columns and 200,000 rows then unpivoting would produce a table with 100 million rows which is not far from the table limit size in EasyMorph.

Dealing with larger tables is still possible, but that would require iterating the source table and aggregating one product at a time in each iteration.

**** moved to #uncategorized

Oh brillant !! Thank you sooo much !