doubt in groupby: Question about List and Sum

Hello, guys!

I’ll put it in context for you. I can have several CNPJ (a type of registration) for each distributor CNPJ (as if it were the central registration). However, I need the result for the distributor and the CNPJ, so I put it in the aggregation manual as a sum and as a list, but it returns millions of lines, many even repeated. A duplicate row filter doesn’t seem ideal to me and I suspect the joiner made earlier, but which only had 2 equivalent columns and I used the 2 I could. When I do a groupby bringing only the result as a sum without being a list, it returns the expected amount before the joiner. Some help? Needed as a list to look at the CNPJ individually



Hi,
Can you show us the original table + an example result? Because I do not really understand what you are attempting. In your last screenshot, RESULT_GROUP has type Double (D), but in your screenshot it is String (S).
Kind regards,
Alexander

1 Like

Of course. below are the two tables, the columns that I use for the joiner in the next step and then the groupby that I use bringing the sell out as a sum (which returns by distributor and not by CNPJ PDV)





Hi,
So you join the two tables first? Is each combination of distributor and CNPJ PDV unique? Otherwise you might get duplicates after the joiner, because it will create every possible combination from the matching rows in both tables. After that, you have many columns as Group columns in the GroupBy. Can’t you just use CNPJ PDV and Distribuidor there? That should give you the sum for each distributor and CNPJ PDV combination.
Kind regards,
Alexander

1 Like

Hi @Cairo , in one of your screenshots you apear to be including Sell In Q2'22 among your grouping columns but this looks to be a financial value so not something you’d normally group by.

Of course we can’t see your actual data so it could be that it only has one value for the combination of other grouping columns and you are just including it so that the value is returned but it seems a little strange.

1 Like

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