MongoDb cube: create a parameter to filter a date field by year (month, day)

8 views
Skip to first unread message

Q&A Bot

unread,
Apr 21, 2021, 6:11:36 AMApr 21
to seektab...@googlegroups.com

Q:
Is it possible to add a report parameter which shows months and when we choose month corresponding data for that month visible?

When your MongoDb documents contain a date field SeekTable automatically adds 'date-part' dimensions (year / month / day) and they are selected as a projection like this:
{$cond: [{ $ifNull: ["$orderDate", 0] }, {$year:"$orderDate"}, -1]}
To create a report parameter that filters by the date part:
  1. Add a report parameter with Data Type=Int32 (String is not suitable) -- let's assume that parameter's name is "orderDate_year_filter".
  2. In the "Filter JSON" add this placeholder to apply the filter in the MongoDb query:
    { $and: [    {"_id":{$exists:true}},   @orderDate_year_filter[ {{ "$expr": {{ "$eq": [{{ $year: "$orderDate" }}, {0}]] }} }}, ]    ]}
See also SeekTable help page on the parameters for MongoDb-based cube: https://www.seektable.com/help/mongodb-pivot-table#parameters
Reply all
Reply to author
Forward
0 new messages