Skip to main content
Oct 20, 2021 10:04 AM UTC
Question

Sum distinct values

I want to sum only distinct values. And here´s my problem. I created a variable with the order and the position of the order (CONCAT VKBEL & POS). And now I want to SUM the amount of the order quantity of all variables. But the variable occurs more than once. Is there a function that only sum distinct values? Thanks in advance for any ideas.

4 replies

Oct 20, 2021 10:14 AM UTC

​or is there a possibility to filter out the variable that occurs more than once?

Oct 20, 2021 1:52 PM UTC

Hi Silvia,

 

I think this could be a solution:

SUM(PU_FIRST(DOMAIN_TABLE(VKBEL. POS),VALUE)) , you might need to e.g. use a MAX or an ORDER BY to get the right value as I don't know your exact situation.

 

Does that help? Good luck,

Lucas

Nov 10, 2021 10:21 AM UTC

Dear Lucas, thank you so much for your fast reply. I found a solution for my problem. I have aggregated my data on the wrong table. Now I use the VBAP and pull the data from the VBFA to the VBAP that I don´t need the variable anymore and create only one line per case.

Unfortunatly the Domain_Table function did not work in my case (maybe I didn´t use it properly) so I have to find this other way.

 

Regards,

 

Silvia

Level 0
Nov 30, 2021 1:00 AM UTC

Hi Silvia,

 

I believe you are now aggregating directly in the case level (VBAP), so something like

PU_COUNT(VBAP,VBFA.RFMNG_FLO)

 

But if you want to aggregate to the Sales Order Level, you can use the DOMAIN_TABLE. This function creates a virtual table and is commonly use when the tables are not directly connected.

Alternatively, you can also check the BIND() function that has a similar functionality

celonis.cloud/help/display/CIBC/BIND

Best,

Gabriel