Convert MDX fields to SQL
Saturday, December 15th, 2007A number of our customers have reporting systems that use both MDX and SQL, retrieving data from both OLAP and SQL Server databases. This generates the problem of converting an MDX field ([Dimension].[Hierarchy].&[Attribute]) into SQL Server field value (Attribute). The following code is a Reporting Services custom code section that will rip off the MDX and leave you with the value.
Public Function MDXParamToSQL(Parameter As String, All As String) As String
Dim Val As String
Val = ParameterIf Val.Contains(”[”) Then
If Val.ToLower().Contains(”].[all]”) Then
Return All
Else
Val = Val.Substring(1, Val.LastIndexOf(”]”) - 1)
Val = Val.Substring(Val.LastIndexOf(”[”) + 1)
Return Val
End If
Else
Return Val
End IfEnd Function
No comments:
Post a Comment