I am hoping to get a view of the average over time...
# gd-beginners
h
I am hoping to get a view of the average over time, but so far the COUNT MAQL has been throwing me for a loop
Our data model looks like this:
However, Jacques suggests a syntax of
SELECT COUNT(Employee ID, Records of Ticket Replies)
which is not available to us (assuming I substitute ID (Portal Users) for Employee ID and do something like Records of Viewing Requests for Records of Ticket Replies.
I can write
SELECT COUNT(ID (Portal Users), ID (VR))
but this returns the number of applicants who have made a request, not the amount of requests per applicant.
j
Hi, I suppose “ID (VR)” is unique key of a request. If this is the case you can do
SELECT COUNT( ID(VR) )
to count number of unique requests. Attribute “Records of _dataset_” is created in case there is no primary key in fact dataset defined. You can use it to count records of this dataset (e.g.
SELECT COUNT(Records of Ticket Replies
)
h
but how do I get from counting the number of unique requests across the entire database to finding out the number of unique requests per applicant?
i.e. how do I set a Count of ID per Portal User?
I would like to know the average number of requests
j
you can use the same metric together with Portal User in “Rows”
h
the screenshot I shared came from the visual editor (analyse tab). How would I get it from a huge list to an average number, i.e. last week, the average number of requests per portal users was x
j
the same metric can count all requests together, number of requests per portal user, number of requests per day etc.
h
so basically if I wanted to do an average I would need to do: COUNT (VR) / COUNT (USER ID)
j
select avg(select count(Records of Ticket Replies) by Portal User)
h
I don't have the Records of Viewing Request option in our system
j
or
select count(Records of Ticket Replies)/count(Portal User)
h
i.e. we lack the equivalent to the metric that the article describes
j
so which key identifies request in your data model?
h
image.png
j
so you can define: • metric Number of requests as`select count(id(VR))`
h
yes
j
• metric number of users as
select count(ID (Portal User)
h
and then COUNT (VR) / COUNT (USER ID)?
j
and average requests per user as:
select Number of requests / Number of users
or
select count(Id(VR))/count(Id (Portal User))
or
select avg(select Number of Requests by Id(Portal user))
or
select avg(select count(Id (VR)) by Id (Portal User)
I think the first two options will count users without requests as 0. The last two options will count average from users who had some requests.
h
thank you, that's really helpful
j
btw. you can also count number of users with some requests (basically number of unique values in foreign key using:
select count(Id (Portal User), Id (VR))
The average number of requests per user who had a request can be then computed without the AVG function as:
select count(Id(VR)) / count(Id (Portal User), Id (VR))
h
🤔 that is an interesting approach