Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Designing Analytics Reports
Using a date parameter with mongodb aggregation
Migrateduser
<p>I'm trying to write a report that gets data from a mongodb using Birt 4.3.</p><p>The documents which record logins look like this</p><p> </p><p>[font="'courier new', courier, monospace;"]{<br />
"_id" : ObjectId("5208ff1c2d5df25629d115bf"),<br />
"status" : "A",<br />
"accountNo" : "UY675820415307047356",[/font]</p><p>[font="'courier new', courier, monospace;"] "location" : "UK"<br />
"timestamp" : ISODate("2013-08-12T15:28:28.388Z")<br />
}[/font]</p><p> </p><p>My issue is that I need to present the data in the following way:</p><p>1) limit data by a time period defined by 2 report parameters startDate & endDate</p><p>2) group the data by accountNo, counting the logins for each account and also the total logins</p><p> </p><p>So, I have tried to use the Command Expression of the query builder with the following expression:</p><p> </p><p>[font="'courier new', courier, monospace;"]{ $match: { timestamp: {$gte:'?',$lte:'?'} } },<br />
{ $group : <br />
{ _id : <br />
{ accountNo : "$accountNo",<br />
location: "$location"<br />
},<br />
totalSignonsPerAccount : { $sum : 1},<br />
totalSignons : { $sum : "$totalSignonsPerAccount"}<br />
}<br />
}[/font]</p><p> </p><p>The $group part of the aggregation pipeline works fine, but I cannot figure out how to write the $match portion.</p><p> </p><p>If I change the $match to use the status property e.g.</p><p> </p><p>[font="'courier new', courier, monospace;"]{ $match: { status: 'A' } },[/font]</p><p> </p><p>it works fine, but I can't for the life of me figure out how to get it to work with date parameters against the timestamp property .</p><p> </p><p>I have the same date parameters in filters on other data sets that don't require any aggregation and they work without issue.</p><p> </p><p>Anyone got any clues?</p><p> </p><p>Cheers</p>
Find more posts tagged with
Comments
There are no comments yet