SSRS : How to Use RegEX (Regular Expression) on Multivalue Parameter.

In some Cases we need validate /correct the input value .In SSRS when we want to enter MSISDN number  which is generally   11 digits (32NNNNNNNNN)  so we cannot give interger datatype .
Due to this we need to take as text and Use is able to enter in different formats /styles . we need to use regex to get only required format .

Workaround . Step 1 . create a Input parameter  (example @MSISDN) of type Text which allows multiple values
Step2 : Create another Hidden Parameter to  MSIDN_RegEX 
Where in default value use

=System.Text.RegularExpressions.Regex.Replace(join(Parameters!MSISDN.Value,","), "[^0-9,]", "")


This RegEX will remove all characters Except “,” and replace with “”


Step 3 : Create another Parameter called Query of Text datatype .
In that
Select Column1 ,…Columnn from Table where MSIDN in( @MSISDN_ )

Step 4 : Create a Dataset Main

NOTE for getting fields Metadata run the query Select Column1 ,…Columnn from Table

After that in Expression of dataset

=replace(Parameters!Query_.Value,"@MSISDN_", Parameters!MSISDN_RegEX.Value)

Comments

Popular posts from this blog

SSAS : A connection cannot be made to redirector. Ensure that 'SQL Browser' service is running. (Microsoft.AnalysisServices.AdomdClient). + Solution

SSIS Error : Unable to infer the XSD from the XML file. The XML contains multiple namespaces