Hi Team, I was looking for some help with metrics...
# gooddata-cloud
r
Hi Team, I was looking for some help with metrics that should return a value e.g. count of IDs where a certain attribute is not null. I've been looking at the NOT logical operator to return e.g. count of users who have at least one user skills id associated - would this be correct syntax or is there a better way to return this? _SELECT COUNT({label/users.id}) WHERE NOT ({label/user_skills.id}) = NULL_ or for count of users who have at least one skill rating SELECT ({metric/count_of_users_with_associated_user_skill}) WHERE NOT ({fact/ownrating}=NULL) Any help pointing me in the right direction would be appreciated, thanks!
👀 1
An alternative to NOT I was exploring was also <> NULL, but I am unclear which one would be the best route
m
Hi Raffaella, thank you for this. at first glance I would use the first one, can you clarify if both of them are working? To understand better, can you please share the workspace or insight (by DM). Also in some cases, you can use
SELECT COUNT({label/users.id}) WHERE NOT ({label/_user_skills.id_}) = ""
And in our documentation of Relational Operators, you can see more examples at the bottom of the page.
Yeah, we replied at the same time 😄 , in the suggested documentation you can see also this '<>' operator.
Hi Raffaela, I’ve been reviewing your case, and both options you mentioned are actually valid and yield the same results. However, I recommend using '<>' as it is more concise and does not resemble a 'double negative' (e.g., NOT (Attribute) = NULL), which makes your metric easier to read. Also, please keep in mind that each user.id can have multiple user_skills.id entries. Therefore, when you are counting 'at least' one skill per user.id, it's possible for more than one user_skill.id to meet your condition. However, it will still only count as one. Let me know if you have any questions!
r
Thank you so much for the advice, Mauricio, really helpful 🙂