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

Skip to first unread message

Q&A Bot

Apr 21, 2021, 6:11:36 AM4/21/21

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:
Reply all
Reply to author
0 new messages