Problem with aggregate function in ACS | Community
Skip to main content
pierre-yvesm520
Level 2
Dec 6, 2018 11:37 AM UTC
Solved

Problem with aggregate function in ACS

Hello, I have a problem using aggregate function in ACS.

When I add an additionnal data wich is based on the SUM() function in a simple query activity, I get a PostgreSQL Error : column "n1.irecipientid" must appear in the GROUP BY clause or be used in an aggregate function.

I can't do any aggregate, could you help me please.

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
asish_kumarp599
asish_kumarp599Accepted solution
Level 4
Dec 16, 2018 8:45 PM UTC

Thanks for sharing the screenshots! Here are my comments:

  • I think you are using the avg function available in the 'Expression Editor'?  Unfortunately, these Aggregate functions available in query editor are not quite efficient in the 'Additional data' section of query editor . Also, to fulfill your requirement there is no Group By function with Aggregate function here.
  • However, these Aggregate functions works quite well in 'Extract file' activity. You can use the Avg function in the output column section and the use Transfer file activity to export the data. I am not sure this works for you but I see this is only way to get the avg function work.

12 replies

jyotiy2857946
New Participant
May 21, 2020 7:38 AM UTC

Hi,

 

You can perform aggregate in Query, as shown below:

 

Add Group by line and you will be able to execute query without error.

 

Thanks.

 

Translate
pierre-yvesm520
Level 2
Dec 17, 2018 8:06 AM UTC

OK Thanks to both of you for your answers.

asish kumarp59945245  : I'll find a way to perform the calculation I need without using the agregate functions on the advanced expression editor then.

anasso21228396​ : I could effectively use the collections to perform agregate calculations (but i'll have to adapt my workflow before)

Translate
Level 3
Dec 17, 2018 12:20 AM UTC

Salut Pierre-Yves,

Pour un besoin similaire, j'ai configuré la même Query que toi. ça semble logique, mais j'ai pris le temps de comprendre pourquoi ça ne fonctionne pas, avant de trouver une solution de contournement que je partage volontiers en anglais :

The aggregate functions don't work with simple fields, only with collections :

The average profile age can be calculated by creating a Profile collection using Additional data in the main query and the Enrichment activity :

  • In your main query add as an additional data a constant text field labeled 'Collection Link' :

  • Add an Enrichment activity. In advanced Relations, Add an element with this definition :

  • Add new additional data with the profile collection we just created :

  • In the new window that pops up, go to Data and Create Element as follow :

Confirm all and run workflow. The field Avg(Age) should be added to Profile Collection.

Translate
Level 2
Oct 20, 2022 7:37 AM UTC

I've been coming back to this post many times but it hasn't been before now that I really understood and could make us of that solution. In my use case I wanted to aggregate and SUM on a specific contactID so I used that as the "GROUP BY" in the enrichment activity followed by a dedup activity.

Translate
asish_kumarp599
asish_kumarp599Accepted solution
Level 4
Dec 16, 2018 8:45 PM UTC

Thanks for sharing the screenshots! Here are my comments:

  • I think you are using the avg function available in the 'Expression Editor'?  Unfortunately, these Aggregate functions available in query editor are not quite efficient in the 'Additional data' section of query editor . Also, to fulfill your requirement there is no Group By function with Aggregate function here.
  • However, these Aggregate functions works quite well in 'Extract file' activity. You can use the Avg function in the output column section and the use Transfer file activity to export the data. I am not sure this works for you but I see this is only way to get the avg function work.
Translate
pierre-yvesm520
Level 2
Dec 16, 2018 1:31 PM UTC

Translate
pierre-yvesm520
Level 2
Dec 16, 2018 1:30 PM UTC

Translate
asish_kumarp599
Level 4
Dec 15, 2018 10:53 PM UTC

Can you please share the Screenshot of your Properties & General tab. It may occur if your targeting dimension is not Profile.

Translate
pierre-yvesm520
Level 2
Dec 12, 2018 3:34 PM UTC

Hello,

The query in on profiles for example, see below.

- Profile : Has children = Yes

And in additionnal Data :

- Average(age)

This cause an error in the query  :

I hope my post is detailed enough.

Thanks in advance

Translate
asktam1410
Level 3
Dec 11, 2018 6:06 PM UTC

Post the query which you are trying

Translate
pierre-yvesm520
Level 2
Dec 11, 2018 3:00 PM UTC

Hello,

I dont have such options, I working on Adobe Campaign Standard (ACS) and the only option avaliable is to remove duplicate rows :

(The screenshot is from a french version)

Translate