Hi @nathanael
Have a look here: Custom mongodb query in metabase
You should read the Mongo documentation as well: https://docs.mongodb.com/manual/reference/operator/aggregation/lookup/
Hi Metabase Team, How can i count distinct "id" in mongodb in metabase platform.
when i am using $count function it is giving error to me :-
$group:
{
_id: null,
sku_count: {$count : "sku"}
}
Please suggest me what would be the right syntax if i just want to count without any filter condition.
@oshimmahajan Use the GUI to do it, then click the "View the native query" in the Notebook to see the query.
https://www.metabase.com/docs/latest/users-guide/04-asking-questions.html#viewing-the-sql-that-powers-your-question
From where i get the view the native query option? didn't get you
@oshimmahajan I have no idea what you are asking for then. Try linking to the Mongo documentation page of what you are trying to do.
I am looking for count(distinct sku('column name') here.
@oshimmahajan I don't know what sku()
is. Perhaps you'll find better help in a Mongo specific forum, since Metabase does not have such function, so you would need to do it in Native query.
Sku is a column name .
@oshimmahajan Okay, then exactly what I showed is how you do it in the GUI, "Number of distinct values of..."
Hi flamber, how can we lookup another collection in Metabase since we need to choose the base table from the dropdown only in case of Mongodb?
Hi @flamber , I am facing issue in filtering of Metabase-MongoDB .
This is user interactive filter : {"$match" : { "$and": [ { "Store_Name": {{Store_Name}} } ] }}
but visualisation needs atleast one input value and it will not work if i don't want to put any value in the filter. please assist.
Hi @nathanael, how can we lookup another collection in Metabase since we need to choose the base table from the dropdown only in case of Mongodb?
Also, I am facing issue in filtering of Metabase-MongoDB .
This is user interactive filter : {"$match" : { "$and": [ { "Store_Name": {{Store_Name}} } ] }}
but visualisation needs atleast one input value and it will not work if i don't want to put any value in the filter. please assist.
@oshimmahajan I don't understand what you mean. Open a new topic, since it has nothing to do with this.
Field Filters have a different syntax that simple variables. Please read https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html#the-field-filter-variable-type and https://www.metabase.com/learn/sql-questions/field-filters
Hi @nathanael, @flamber , i meant that filter is not working, when i am adding value to the filter, it is not showing any result. pfa screenshot attached.
It is not working for store_name also, i have tried it without $eq also. But for created_at , it is working.
@oshimmahajan Mongo uses this syntax for Field Filters as shown in the documentation:
{$match: {{raena_username}} }
Please read the entire documentation for variables:
https://www.metabase.com/docs/latest/users-guide/13-sql-parameters.html
And simplify your query, when trying to debug problems. And include your entire query in plain text, when asking for help.
Sure @flamber , Thanks for helping , everything works in case of filter.
Can you please provide any document which shows how we can join (lookup) two collections in metabase-mongodb.
@oshimmahajan Have a look at Custom mongodb query in metabase, which is also linked in the first comment of this topic.
Please open new topics if you have any other questions or problems.