{"id":372,"date":"2012-05-25T13:24:36","date_gmt":"2012-05-25T18:24:36","guid":{"rendered":"http:\/\/mkncreations.com\/sandbox\/mknwp\/?p=372"},"modified":"2015-09-15T20:11:56","modified_gmt":"2015-09-16T01:11:56","slug":"filter-top-n-group-totals","status":"publish","type":"post","link":"https:\/\/mkncreations.com\/site\/2012\/05\/filter-top-n-group-totals\/","title":{"rendered":"Filter Top N Group Totals"},"content":{"rendered":"<p>Lets say you have a dataset that is returning a bunch of rows but you have a top N or some kind of a filter that will display only the Top N rows base on a criteria. Well most likely you have a filter set up under the Details Group. Now you want to have a sum of the totals for the Top N results. Well if you just use Sum(Fields!name.Value) the SSRS will return the SUM of all rows generated by the dataset in your report and not the SUM of only the Top N results shown on your report.<br \/>\nSo here is the solution:<\/p>\n<p><strong>For a Table:<\/strong><\/p>\n<p>Lets say you have Grouped by Product.Name so in your Row Groups you will have something like this:<\/p>\n<div>\n<blockquote><p> [\u00a0(ProductName)<br \/>\n=\u00a0(Details) <\/p><\/blockquote>\n<\/div>\n<p>And you would like to filter the Top 10 Products so in that case if you right click (Details) the Group Properties under filters you will have a filter condition defined which in result will make the report return only the Top 10 Products.<br \/>\n1. Create 1 additional row that is inside the Details group. You can do that by right clicking the row that will show the Details and then choose Insert Row bellow.<br \/>\n2. In that newly created row enter this Expression:<\/p>\n<div>\n<blockquote><p> =RunningValue(Fields!Ammount.Value,\u00a0Sum,\u00a0&#8220;ProductName&#8221; <\/p><\/blockquote>\n<\/div>\n<p>and Hide the whole row<br \/>\n3. Right click the (Details) group and select Add Total -&gt; After<br \/>\n4. In the newly created Row enter this expression:<\/p>\n<div>\n<blockquote><p> =reportitems!AmmountSubtotals.value <\/p><\/blockquote>\n<\/div>\n<p>where AmmountSubtotals in my case is the name of the Textbox created in step 2.<br \/>\nEnjoy!<\/p>\n<p><strong>For Matrix:<\/strong><\/p>\n<p>Same method like the above one but after you create the Matrix you need to go to the Column Group where you most likely will have only 1 Group in there. So right click it then select Add group -&gt; Child Group -&gt; check Show detailed data.<br \/>\nThen add the columns needed and Add Totals for the column where you will show the result with the Expression:<\/p>\n<div>\n<blockquote><p> =reportitems!AmmountSubtotals.value <\/p><\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Lets say you have a dataset that is returning a bunch of rows but you have a top N or some kind of a filter&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,11],"tags":[40,41,38,43,42,39],"class_list":["post-372","post","type-post","status-publish","format-standard","hentry","category-how_to","category-ssrs","tag-filter","tag-groups","tag-ssrs-2","tag-sum","tag-top","tag-topn"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/372"}],"collection":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/comments?post=372"}],"version-history":[{"count":4,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/372\/revisions"}],"predecessor-version":[{"id":276456,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/372\/revisions\/276456"}],"wp:attachment":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/media?parent=372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/categories?post=372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/tags?post=372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}