{"id":133,"date":"2008-04-27T08:13:00","date_gmt":"2008-04-27T08:13:00","guid":{"rendered":"\/lisa\/post\/2008\/04\/27\/Sometimes-the-magic-works.aspx"},"modified":"2008-04-27T08:13:00","modified_gmt":"2008-04-27T08:13:00","slug":"sometimes-the-magic-works","status":"publish","type":"post","link":"https:\/\/spacefold.com\/lisa\/2008\/04\/27\/sometimes-the-magic-works\/","title":{"rendered":"Sometimes the magic works"},"content":{"rendered":"<p>\nUma (<a href=\"mailto:uma159@gmail.com\" target=\"_blank\" title=\"uma's address\" rel=\"noopener\">whoever that is<\/a>) has posted a question in response to <a href=\"\/lisa\/2007\/09\/19\/Dynamically-loading-reports-in-ReportViewers\/\">https:\/\/spacefold.com\/lisa\/2007\/09\/19\/Dynamically-loading-reports-in-ReportViewers<\/a><a href=\"\/lisa\/Dynamically-loading-reports-in-ReportViewers\/\" title=\"an RS post on dynamically loading reports\"><\/a>&nbsp;, which as far as I can tell is completely unrelated to that post &lt;g&gt;.\n<\/p>\n<blockquote>\n<p>\n\tHi i want to display subtotal of first page in the top of next page in rdlc report and i am using page break of 10 in every page.\n\t<\/p>\n<\/blockquote>\n<p>\nUnrelated to dynamically loading reports&nbsp;or not,&nbsp;the question&nbsp;certainly covers a subject that I&#39;m familiar with and will address here in case I haven&#39;t in the past.\n<\/p>\n<p>\nFirst, just in case&nbsp;I haven&#39;t already talked about conditional page breaks on &lt;item number&gt;, this is just a variant of other ROW_NUMBER() techniques we&#39;ve used to resolve past problems.&nbsp; Let&#39;s say my SQL query looks something like this, in Uma&#39;s case:\n<\/p>\n<p class=\"code\">\n&nbsp;SELECT <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sales_No, Customer,Order_Quantity, <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CEILING(CAST( ROW_NUMBER() OVER (ORDER BY Customer)&nbsp; \/ 10&nbsp; AS <br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Numeric(10,2))) AS Grouper<br \/>\n&nbsp;FROM OrderHeader <br \/>\nORDER BY Customer\n<\/p>\n<p>\n&#8230; where the &quot;<strong>\/10<\/strong>&quot; in the above query is determined by the &quot;page break of 10&quot; in Uma&#39;s scenario.&nbsp; OK so far?\n<\/p>\n<p>\nSo now my group break is simply the expression <strong>=Fields!Grouper.Value<\/strong>, and I set this group to <strong>page break at end.&nbsp; <\/strong>\n<\/p>\n<p>\nNB: I&nbsp;always think it&#39;s nice to let SQL do most of the work, if I can.\n<\/p>\n<p>\nIn your situation, you might be doing it differently, or in a more RS-oriented way.&nbsp; That&#39;s okay, how you happen to be determining your page break is not really germane to Uma&#39;s question at all. The point is, however you&#39;re doing your grouping&#8230; the work is almost all done already.&nbsp; It <em>looks<\/em> as though we have a lot of work left, maybe, but really, it&#39;s almost done.\n<\/p>\n<p>\nSo now&nbsp;let&#39;s say we have a subtotal expression (for Uma) that, in my example, looks like this, in the footer of this group: <strong>=Sum(Fields!Order_Quantity.Value).<\/strong>\n<\/p>\n<p>\nAnd&nbsp;let&#39;s say we change that footer expression to do this: <strong>=Sum(Fields!Order_Quantity.Value) &amp; Code.MyUdf(Sum(Fields!Order_Quantity.Value))<\/strong>.\n<\/p>\n<p>\nAnd let&#39;s say we write the following (really minimal) amount of code:\n<\/p>\n<p class=\"code\">\n&nbsp;&nbsp; Public PrevPage As Double = 0<\/p>\n<p>&nbsp;&nbsp; Function MyUdf( t As Double) AS String<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;PrevPage = t<br \/>\n&nbsp;&nbsp; Return &quot;&quot;<br \/>\n&nbsp;&nbsp; End Function\n<\/p>\n<p>\n&#8230; &nbsp;&nbsp;and now let&#39;s say we put a textbox in the group <em>header<\/em> with the following expression: =<strong>IIF(Code.PrevPage = 0,&quot;&quot;,Code.PrevPage)<\/strong> (the IIF() is just to take care of the first page, because I&#39;m too lazy to worry about whether this is the most elegant way to do it or not).\n<\/p>\n<p>\nThat&#39;s all she wrote, folks.&nbsp; Seems to work just as you&#39;d want.&nbsp; No big deal, really.\n<\/p>\n<h4>Why the title of this post?<\/h4>\n<p>\nFirst, you should know it&#39;s a quote from &quot;<a href=\"http:\/\/www.imdb.com\/title\/tt0065988\/quotes\" target=\"_blank\" title=\"movie homage for the day\" rel=\"noopener\">Little Big Man<\/a>&quot;.&nbsp; I&#39;m taking a &quot;<a href=\"http:\/\/www.browncoats.com\/\" target=\"_blank\" title=\"yeah but I'm still a browncoat\" rel=\"noopener\">Serenity<\/a>&quot; break, just for kicks.\n<\/p>\n<p>\nSecond, this is one of those times when multiple export types (Excel rendererer, PDF renderer, etc) don&#39;t get in the way. You notice I haven&#39;t put anything in the page header; I&#39;m avoiding any issues of &quot;what sequence does everything happen in&quot; in the various rendering engines that way.&nbsp; Sometimes the magic can&#8230; just work.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Uma (whoever that is) has posted a question in response to https:\/\/spacefold.com\/lisa\/2007\/09\/19\/Dynamically-loading-reports-in-ReportViewers&nbsp;, which as far as I can tell is completely unrelated to that post &lt;g&gt;. Hi i want to display subtotal of first page in the top of next page in rdlc report and i am using page break of 10 in every page.<a class=\"more-link\" href=\"https:\/\/spacefold.com\/lisa\/2008\/04\/27\/sometimes-the-magic-works\/\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,6],"tags":[],"class_list":["post-133","post","type-post","status-publish","format-standard","hentry","category-reporting","category-sql-server"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/comments?post=133"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/133\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/media?parent=133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/categories?post=133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/tags?post=133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}