Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

aggregation query in tmongoDBInput

Hi,

 

I used below query in tmongodbinnput and it worked fine.

"{'$group':{'_id' : {'name':'$product.name','id':'$product.onairId'}, 'total' : {'$max' : '$prgDate'}}}"

 

But now I am using 

"{'$unwind': {'path' : '$grid'}},{'$group' :{'_id':'$grid.product.name','total':{'$max':'$dealCreatedAt'}}"

 

and it is not throwing any error, but it is just unwinding and returning all documents instead of grouping them.

 

Can anyone please tell how to unwind an array of objects and then do a group and find max of something?

 

Regards

Ravinder

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I found the solution after many trials.

 

I just used 2 stages by specifically adding 2 stages in tmongoInput aggregation pipeline mode.

stage 1 : "{$unwind : {path : '$grid'}}"

stage 2 :  "{$group : {_id : '$grid.product.name','total': {$max : '$dealCreatedAt'}}}"

 

 

 

 

View solution in original post

2 Replies
Anonymous
Not applicable
Author

I found the solution after many trials.

 

I just used 2 stages by specifically adding 2 stages in tmongoInput aggregation pipeline mode.

stage 1 : "{$unwind : {path : '$grid'}}"

stage 2 :  "{$group : {_id : '$grid.product.name','total': {$max : '$dealCreatedAt'}}}"

 

 

 

 

Anonymous
Not applicable
Author

Hi when i try to run query:-

"{'$group':{'_id' : {'_wellname':'$_wellname','_datasetname':'$_datsetname','_variablename':'$_variablename'}, 'total' : {'$sum' : 1}}}"

 

i get only count ,all columns are blank in output file.

 

I want count by column name passed in my query