{"id":70,"date":"2011-01-17T06:01:00","date_gmt":"2011-01-17T06:01:00","guid":{"rendered":"\/lisa\/post\/2011\/01\/17\/Walkthrough-on-BlankNull-Multi-Value-Parameters-The-Quick-and-the-Dead.aspx"},"modified":"2011-01-17T06:01:00","modified_gmt":"2011-01-17T06:01:00","slug":"walkthrough-on-blank-null-multi-value-parameters-the-quick-and-the-dead","status":"publish","type":"post","link":"https:\/\/spacefold.com\/lisa\/2011\/01\/17\/walkthrough-on-blank-null-multi-value-parameters-the-quick-and-the-dead\/","title":{"rendered":"Walkthrough on Blank\/Null Multi-Value Parameters: The Quick and the Dead"},"content":{"rendered":"<p>Today I&#8217;m going to show you a simple trick that might help you out with multi-value parameters. Then I&#8217;ll show you a bug with parameter deployment that you&#8217;ll easily see as we walk through this trick.<\/p>\n<p>The bug isn&#8217;t specific to the trick, and in fact in the walkthrough scenario it doesn&#8217;t do any real harm. However, in more complex real-life report deployments, you may find it bites you very hard in the rear end &#8212; as I happened to find last week.<\/p>\n<p>You may already know the trick (it&#8217;s VERY simple), but read on anyway in case this deployment bug surfaces in your professional life.<\/p>\n<p>I&#8217;m going to show you all this in 2008 R2. In production, where the bug showed up, we&#8217;re not using R2 yet. When I easily duplicated the problem in R2, I thought I&#8217;d better show you. So let&#8217;s get started.<\/p>\n<p class=\"NB\"><strong>A quick sidebar<\/strong> <\/p>\n<p>Speaking of versionitis, I was going to upload and discuss a bug-repro having to do with different optimizations of code attached to conditionally Hidden (or Toggled) objects done by different renderers, having found that <a title=\"blog post following up on the bug for the XML renderer\" href=\"\/lisa\/2010\/12\/19\/Blunted-points\/\">neither the XML renderer<\/a>&nbsp;<a title=\"original blog post discussing the problem with the Excel renderer in focus\" href=\"\/lisa\/2010\/12\/12\/Everything-has-a-point-Part-Deux\/\">nor the Excel renderer <\/a>faithfully reproduced the actual contents (never mind the formatting) of the interactive version. <\/p>\n<p>I haven&#8217;t done so because I found that, in R2, the interactive version also &lt;cough&gt; optimized the code away.&nbsp; It didn&#8217;t execute until you toggled the detail code visible &#8212; at which time <strong>all<\/strong> the summary lines for details <strong>later<\/strong> than this one suddenly had the right contents (the summary lines <strong>above<\/strong>&nbsp;the toggled one remained incorrect).&nbsp; <\/p>\n<p>This was mildly amusing to watch&#8230; in a bitter sort of way.&nbsp; But, as a result, I was much less motivated to share the renderer-specific behavior with you, and much more motivated to come up with a completely different way to handle the original requirement.&nbsp; It&#8217;s still in an SSRS format, of course, but the code is stripped out and placed&nbsp;in TSQL&nbsp;code that creates a DW table, refreshed nightly, with the results of all the calculations.<\/p>\n<p>For any of you that are in the California K12 world, you might be interested to know that the calculations in question evaluate a student&#8217;s &nbsp;status with respect to state university entrance requirements, are non-trivial, and can be found <a title=\"California University Entrance Requirements - subject version\" href=\"http:\/\/www.universityofcalifornia.edu\/admissions\/freshman\/california-residents\/statewide-path\/subject-requirement\/index.html\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<h2>Setup<\/h2>\n<p>Suppose you have a report with a couple of cascading parameters, both derived from a query.&nbsp; In my example I&#8217;ll use the Continent-&gt;Country-&gt;City relationship that exists in my standard SQLWorld database, borrowed from the MySQL tutorials.&nbsp; The sample report is simplicity itself.&nbsp; The cascading parameters part probably isn&#8217;t even necessary, you just need a single parameter that derives from a query.&nbsp; We&#8217;ll focus on the Country parameter here.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeployOriginalReport.png\" alt=\"\" \/><\/p>\n<p>The Country parameter gets its default, as well as its available values, from the paramCountry query.&nbsp; When you first deploy it to the SSRS server, here&#8217;s how the parameters look from the vantage point of the Report Manager interface.&nbsp; For our purposes it doesn&#8217;t matter what method you use to deploy and, again, remember that while your interface might look different if you&#8217;re not using R2, the results and behavior are the same:&nbsp;<\/p>\n<p style=\"TEXT-ALIGN: center\"><img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeploy1.png\" alt=\"\" \/><\/p>\n<p>&#8230; so far so good. Because you get the&nbsp;<strong>available<\/strong> values from the query, in this example, the list of values for Country will refresh each time the user chooses a different Continent.&nbsp; Because you get the <strong>default<\/strong> values from the query, all the Country values are initially selected after the refresh.<\/p>\n<h2>Multi-value dilemma<\/h2>\n<p>So now, for various reasons, let&#8217;s say you don&#8217;t want to rely on the Report Manager UI &#8220;select all&#8221; behavior. You want an explicit value that indicates what you want to do for country selection to the main query for the report.<\/p>\n<p>In my case, it was because I wanted to call the report programmatically.&nbsp; There were also some security complications, not relevant here.&nbsp; The point is that a multi-valued param makes this all a bit difficult to do.&nbsp; As you know, they don&#8217;t allow a null value, which would have been my first choice. for a revision of the main query&#8230;&nbsp;<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeployNullValue.png\" alt=\"\" \/>&nbsp;<\/p>\n<p style=\"text-align: left;\">&#8230; and, while they do seemingly allow blank values, this leads to awkward behavior in interactive use:<\/p>\n<p style=\"TEXT-ALIGN: center\">&nbsp;<img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeployBlankValue.png\" alt=\"\" \/><\/p>\n<h2>Here&#8217;s the simple trick<\/h2>\n<p>Instead of null or blank as a default&nbsp;value,&nbsp;define an explicit value (usually &#8220;All&#8221;, but in my case &#8220;Any&#8221; seemed more appropriate), and add it to your parameter query, like this:<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeployRevisedParameter.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: left;\">The added Priority column simply lets you position the special value wherever you want in the interactive list, in this case at the top:<\/p>\n<p style=\"text-align: center;\">&nbsp;<img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeployRevisedReport.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: left;\">While there isn&#8217;t much difference between the query-based &#8220;All&#8221; and the explicit &#8220;Any&#8221; in this case, the simple trick is quite valuable all the same.&nbsp;<\/p>\n<p style=\"text-align: left;\">Remember what you really want is a NULL or BLANK in this value, to allow the main query to use a completely <strong>different<\/strong> parameter (based on security levels) to lock down to a specific Country list in some instances.&nbsp; The specific Country or Country list in the different parameter (which is hidden and usually blank) might not cascade from Continent, might be completely unrelated to the concerns or privileges of the standard user.&nbsp;<\/p>\n<p style=\"text-align: left;\">In other scenarios, what you really want is a NULL or BLANK for performance reasons.&nbsp; Ignoring the value of the parameter will turn out to be a good idea, as compared with an explicit IN list containing all possible values,&nbsp;where the list is large.<\/p>\n<p style=\"text-align: left;\">In such a case, the &#8220;All&#8221; or &#8220;Any&#8221; value might have a different visual token associated with it, such as &#8220;Unselected&#8221;.&nbsp; It really doesn&#8217;t matter.<\/p>\n<p style=\"text-align: left;\">The point is: this is how you get a functional NULL or BLANK for your multi-valued parameter.<\/p>\n<p style=\"text-align: left;\">You don&#8217;t always realize you&#8217;re going to need to do this, when you first design a report. In my recent case, you re-vamp the report to allow the functional NULL or BLANK later on.&nbsp; This brings me to the real point of my story.<\/p>\n<h2>&nbsp;Here&#8217;s the bug<\/h2>\n<p>You go ahead and make this change, and then you redeploy the report.&nbsp; But here&#8217;s what you (still)&nbsp;see after the redeploy:<\/p>\n<p style=\"text-align: center;\">&nbsp;<img decoding=\"async\" src=\"\/lisa\/wp-non\/migrated\/2011\/1\/ParamDeployRevisedReportParameters.png\" alt=\"\" \/><\/p>\n<p style=\"text-align: left;\">Changing the method of deriving the default value, in the RDL, does not alter the method of deriving the default value in the uploaded report.<\/p>\n<p style=\"text-align: left;\">I&#8217;m usually the first one to defend the behavior of Report Manager and the RS APIs when a report is re-deployed.&nbsp; It makes sense to me that a report deployed to production shouldn&#8217;t automatically (for example) get its datasource revised every time a developer uploads a change.&nbsp; It even makes sense to me (unlike many other people) that the actual default value for a parameter doesn&#8217;t change on a re-deploy; after all, production values may often be quite different.<\/p>\n<p style=\"text-align: left;\">But, in this case, if you need to fix the default value by hand in the deployed version, you really can&#8217;t. You don&#8217;t have any ability to alter the<strong> method of derivation<\/strong> (ie, explicit value\/expression versus query-based) here. That&#8217;s why I think this is a bug.<\/p>\n<p style=\"text-align: left;\">As far as I can see, your only choice is to delete the deployed report and re-introduce it to the installation with a fresh start.&nbsp;&nbsp;&nbsp;This workaround can have all kinds of other unintended consequences if your production deployment <strong>is<\/strong> significantly different from your development version, and you have a lot of parameters to adjust for production. And if you forget to make those adjustments, even once &#8212; or if you don&#8217;t even notice this weird behavior on the first re-deploy, as happened to me &#8212; the report will definitely not run as intended.<\/p>\n<p style=\"text-align: left;\">You&#8217;ve been alerted.&nbsp; If you tend to use multi-valued parameters often, check this out.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I&#8217;m going to show you a simple trick that might help you out with multi-value parameters. Then I&#8217;ll show you a bug with parameter deployment that you&#8217;ll easily see as we walk through this trick. The bug isn&#8217;t specific to the trick, and in fact in the walkthrough scenario it doesn&#8217;t do any real<a class=\"more-link\" href=\"https:\/\/spacefold.com\/lisa\/2011\/01\/17\/walkthrough-on-blank-null-multi-value-parameters-the-quick-and-the-dead\/\">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,12],"tags":[],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-reporting","category-sql-server","category-yaps"],"_links":{"self":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/70","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=70"}],"version-history":[{"count":0,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/posts\/70\/revisions"}],"wp:attachment":[{"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/media?parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/categories?post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spacefold.com\/lisa\/wp-json\/wp\/v2\/tags?post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}