Hello! Can you help me with a MAQL please? I would...
# gd-beginners
g
Hello! Can you help me with a MAQL please? I would like to count distinct contacts that have opened an email title. I'm tryng to use this MAQL but when a contact open an email title twice, it keeps bring 2 on this metric.
SELECT COUNT(*contact ID*, *Records of Contact Campaign Events*) by *Email Title* WHERE *Event Type* = *Email Opened*)
Is it possible to get this distinct count?
m
Hi Gabriela, are you using GoodData platform or GoodData Cloud?
g
Hey Moises! I'm using GoodData Platform
m
Thanks. The count function in MAQL is counting unique records. It seems the duplicity is happening on the data source side as the event that records the number of times an email is opened is recorded separately. I would advise checking if this theory is correct. You can also check an in dept explanation on how the count function works in this community article: How to Use MAQL Count in GoodData Platform | The GoodData Community
g
Hey, thanks for the response! You're right. The event that tracks the number of times an email is opened is logged separately, as a contact can open the same email multiple times. My challenge here is to obtain the count of unique contacts who open each email title, taking into account this behavior in the data source. cc: @Tomas Gomes
m
In this case, you could find the minimun (first) value that correlates to the first recorded event of when the email was openend, then your metric would look like this:
Copy code
SELECT COUNT (contact ID, Records of Contact Campaign Events) WHERE Email Title = (SELECT MIN (Event Type))
You could then apply a filter for Email Opened*.* Note that I don’t have access to your workspace and the metric was not tested with your data.
g
Hey Moises, sorry for took so long here. Actually, after some tests here it works using this MAQL:
Copy code
SUM(((SELECT IFNULL((SELECT COUNT(contact ID, Records of Contact Campaign Events) WHERE Event Type = Email Opened), 0) BY Email Title)))
Thank you so much for the support! Have a great day 🙂
🙌 1
m
Glad to hear it’s working! 🙂 Have a great day you too.