I am trying to build a query with parameters using a calculated member.
I have created calculated members for judicial counts which are “hard coded” and the parameter I created does not effect the totals of each group.
However, I need to have each of the total counts listed with a working parameter. If there is no value for the selected judicial type a zero count should be displayed.
Im sure there is an easy way, but im fairly new to MDX/SSRS. Any help is greatly appreciated!
Here is the query:
WITH
Member [Measures].[Jud] as
(
[Dim Foreclosure Loan].[Judicial Flag].[1],
[Dim Foreclosure Loan].[FCL Stage].&[Sale Held],
[Measures].[Loan Count]
)
Member [Measures].[Non-Jud] as
(
[Dim Foreclosure Loan].[Judicial Flag].[0],
[Dim Foreclosure Loan].[FCL Stage].&[Sale Held],
[Measures].[Loan Count]
)
Member [Measures].[Total] as
(
[Dim Foreclosure Loan].[Judicial Flag],
[Dim Foreclosure Loan].[FCL Stage].&[Sale Held],
[Measures].[Loan Count]
)
-------------------------------- Query Begins --------------------------------
SELECT NON EMPTY
{
([Dim Date].[Calendar].[Day].Members)
} ON ROWS,
NON EMPTY
({
([Measures].[Jud]),
([Measures].[Non-Jud]),
([Measures].[Total])
}) ON COLUMNS
FROM ( SELECT ( STRTOSET(@DimForeclosureLoanJudicialFlag, CONSTRAINED) ) ON COLUMNS
FROM [Foreclosure])
WHERE
(IIF( STRTOSET(@DimForeclosureLoanJudicialFlag, CONSTRAINED).Count = 1,
STRTOSET(@DimForeclosureLoanJudicialFlag, CONSTRAINED),
[Dim Foreclosure Loan].[Judicial Flag].currentmember)
)CELL PROPERTIES VALUE
Update: Need help with the iif statment provided; see comments below.
I’m not 100% clear on what you’re asking but if I were to restate it, I think this is what you’re trying to do. I think you want to see Jud, Non-Jud, and Total on the columns. I think you’re trying to use the parameter to select a particular judicial flag. What’s not clear is whether the parameter values are limited to 1 and 2 as you show for the measures, or if there is a hierarchy there for which there are children for 1 and 2. I’m going to assume the first one because it’s easiest to explain and we can go from there.
You need to set up your measures for the judicial flags 1 and 2 to consider what’s in the
WHEREclause. Right now they are hard-coded and that tells SSAS to ignore whatever is in theWHEREclause. You need to use it conditionally by including anIIFstatement in the Measure definition. You should return aNULLvalue as the False condition so that SSAS can execute the query optimally and then use the format_string property to fill in a zero in place of theNULL(which is better than using the 0 in the False condition for performance). However, yourNON EMPTYkeyword on columns will eliminate the judicial flag that’s not included in theWHEREclause so you need to remove that. Keep it on rows so that you display only the days that have values for either Jud or Non-Jud.Here’s an attempt at your query based on my guess of what you’re trying to do: