MongoDb: Filter JSON with Report parameter $in

14 views
Skip to first unread message

mpan

unread,
Jul 26, 2021, 3:49:48 AMJul 26
to seektable-users
I'm looking to allow a user to specify a Report Parameter in which case I will filter the data using the cube's Filter JSON config. Or if they don't provide a Report Parameter value, exclude that part of the Filter JSON (or treat as a wildcard).

{$and: [{"senderRole":@senderRole},{"senderId":@ssdsid}]}

So for senderRole, ideally they could supply the report param to restrict to only that @senderRole or NOT supply anything and show all senderRole rows. Also acceptable would be to allow a $in where they can enter multiple values in the report param.

Thank you.

VF [SeekTable founder]

unread,
Jul 27, 2021, 10:16:46 AMJul 27
to seektable-users
Take a look to the parameter's placeholder syntax: https://www.seektable.com/help/mongodb-pivot-table#parameters
You can specify part of JSON inside in this way:

{$and: [
   @senderRole[ {{ "senderRole":{0} }}, ]
   {"senderId":@ssdsid}
]}

if 'senderRole' is not defined it is just not included into the filter JSON. Note that inside @senderRole[  ]  "{{" should be used instead of "{" because  these special chars are used to specify parameter's value with {0}.
In similar way you can use "$in" to apply a multi-value parameter:

{$and: [
   @senderRole[  {{ "senderRole": {{ "$in" : {0} }} }}, ]
   {"senderId":@ssdsid}
]}
Reply all
Reply to author
Forward
0 new messages