{"id":526,"date":"2014-09-10T14:55:34","date_gmt":"2014-09-10T19:55:34","guid":{"rendered":"https:\/\/mkncreations.com\/site\/?p=526"},"modified":"2014-09-10T14:58:59","modified_gmt":"2014-09-10T19:58:59","slug":"hiding-columns-based-on-a-multi-select-parameter","status":"publish","type":"post","link":"https:\/\/mkncreations.com\/site\/2014\/09\/hiding-columns-based-on-a-multi-select-parameter\/","title":{"rendered":"Hiding Columns based on a multi-select Parameter"},"content":{"rendered":"<p>If you would like to show and hide certain columns in SSRS here is what you should do.<\/p>\n<p>1. Hit the &#8220;Design&#8221; tab of the report.<br \/>\n2. Go to &#8220;Report&#8221; then from the drop down select &#8220;Report Properties&#8221;<\/p>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/mkncreations.com\/site\/wp-content\/uploads\/report-properties.png\" \/><\/p>\n<p>3. Click on &#8220;Code&#8221; and paste the following:<\/p>\n<blockquote><p>&#8221;&#8217; summary<br \/>\n&#8221;&#8217; Return whether the passed column name has been selected<br \/>\n&#8221;&#8217; in the multi-value parameter, whether it should be visible<br \/>\n&#8221;&#8217; or not.<br \/>\n&#8221;&#8217; end of summary<br \/>\nPublic Shared Function IsColumnSelected(ByRef objMultiValueParam() As Object, ByVal strColumnName As String) As Boolean<\/p>\n<p>&#8216; return whether the passed column name is in the multi-value<br \/>\n&#8216; parameter array<br \/>\nReturn 0 &lt; InStr(vbNullChar &amp; Join(objMultiValueParam, vbNullChar) &amp; _<br \/>\nvbNullChar, vbNullChar &amp; strColumnName &amp; vbNullChar)<\/p>\n<p>End Function<\/p><\/blockquote>\n<p>4. Create a Parameter called &#8220;Show Columns&#8221; with the following Query:<\/p>\n<blockquote><p>SELECT &#8216;Column1&#8217; AS [Label]<br \/>\n, 1 AS [Value]<\/p>\n<p>UNION<\/p>\n<p>SELECT &#8216;Column2&#8217; AS [Label]<br \/>\n, 2 AS [Value]<\/p>\n<p>UNION<\/p>\n<p>SELECT &#8216;Column3&#8217; AS [Label]<br \/>\n, 3 AS [Value]<\/p>\n<p>UNION<\/p>\n<p>SELECT &#8216;Column4&#8217; AS [Label]<br \/>\n, 4 AS [Value]<\/p><\/blockquote>\n<p>Column1, Column2 etc. should be the names of your columns.<\/p>\n<p>5. Under each column select the &#8220;Column Visibility&#8230;&#8221; and paste this expression.<\/p>\n<blockquote><p>=Not Code.IsColumnSelected(Parameters!ShowColumns.Value, &#8220;1&#8221;)<\/p><\/blockquote>\n<p>The expression example above is for Column1. For Column2 you will change it to this:<\/p>\n<blockquote><p>=Not Code.IsColumnSelected(Parameters!ShowColumns.Value, <span style=\"color: #ff0000;\"><strong>&#8220;2&#8221;<\/strong><\/span>)<\/p><\/blockquote>\n<p>So in short you have to 1st map the Columns with numbers that represent them and then in the expression for the column visibility to use the corresponding numbers (values).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you would like to show and hide certain columns in SSRS here is what you should do. 1. Hit the &#8220;Design&#8221; tab of the&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":[138,137,79,21,82,81,136,50,78,38,49,135],"class_list":["post-526","post","type-post","status-publish","format-standard","hentry","category-how_to","category-ssrs","tag-columns","tag-hide","tag-microsoft","tag-ms","tag-multiselect","tag-parameter","tag-show","tag-sql-2","tag-sql2008","tag-ssrs-2","tag-tsql","tag-visibility"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/526"}],"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=526"}],"version-history":[{"count":3,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/526\/revisions"}],"predecessor-version":[{"id":1010776,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/posts\/526\/revisions\/1010776"}],"wp:attachment":[{"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/media?parent=526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/categories?post=526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mkncreations.com\/site\/wp-json\/wp\/v2\/tags?post=526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}