English 中文(简体)
使用计算成员 - MDX 的通过参数
原标题:Passing Parameters using a Calculated member - MDX

我试图用一个计算出来的成员 来建立一个参数查询系统。

我为"硬编码"的司法罪状 创造了计算成员 并且我所设定的参数 并不影响每个组的总数

但是,我需要列出每个总计数,并列出一个工作参数。如果选定的司法类型没有值,则应该显示零计数。

我敢肯定,有一个容易的方法,但对于MDX/SSRS来说是相当新的。非常感激任何帮助!

以下是查询 :

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

<强度 > 更新 :需要帮助提供备注;见下文评论。

最佳回答

我不完全清楚你在问什么,但如果我要重复一遍,我想这就是你试图做的。我想你想在栏目上看到贾德、非朱德和达图尔。我想你正在试图使用参数来选择特定的司法旗帜。不清楚的是,参数值是否限制在1和2,正如你为衡量标准所显示的那样,或者,如果有一个等级,那里有1和2个孩子,我会假设第一个等级,因为它很容易解释,我们可以从那里走。

您需要为司法国旗 1 和 2 设置您的措施, 以考虑 < code> WHERE < /code > 条款中的内容。 现在, 它们是硬码, 并且让 SSAS 忽略 < code> WHERE < /code > 条款中的内容。 您需要有条件地使用它, 在测量定义中加入一个 < code> IIIF < /code > 的语句。 您应该返回一个 < code> NULLL 值, 作为假条件, 以便SSAS 能够最佳地执行查询, 然后使用格式_string 属性填充零, 取代 < code> NULLL (这比在虚假状态中使用 0 更好) 。 然而, 您的 " code> NON EMPTY 关键词会在列中取消未包含在 < code> WHERE < /code > 条款中的司法旗帜, 所以您需要删除它。 保持在行中, 您只显示对Jud 或非 Jud 的日 。

根据我对你想做什么的猜测 尝试查询

WITH 
  MEMBER [Measures].[Jud] AS 
  iif(
        [Dim Foreclosure Loan].[Judicial Flag].CurrentMember is 
            [Dim Foreclosure Loan].[Judicial Flag].[1], 
            (
              [Dim Foreclosure Loan].[Judicial Flag].[1]
             ,[Dim Foreclosure Loan].[FCL Stage].&[Sale Held]
             ,[Measures].[Loan Count]
            ),
            NULL), format_string="#;#;0;0"
  MEMBER [Measures].[Non-Jud] AS 
  iif(
        [Dim Foreclosure Loan].[Judicial Flag].CurrentMember is 
            [Dim Foreclosure Loan].[Judicial Flag].[0], 
            (
              [Dim Foreclosure Loan].[Judicial Flag].[0]
             ,[Dim Foreclosure Loan].[FCL Stage].&[Sale Held]
             ,[Measures].[Loan Count]
            ),
            NULL), format_string="#;#;0;0" 
  MEMBER [Measures].[Total] AS 
    (
      [Dim Foreclosure Loan].[Judicial Flag]
     ,[Dim Foreclosure Loan].[FCL Stage].&[Sale Held]
     ,[Measures].[Loan Count]
    ) 
SELECT 
  NON EMPTY 
    {
      [Dim Date].[Calendar].[Day].MEMBERS
    } ON ROWS
 , 
    {
      [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, FORMATTED_VALUE;
问题回答

暂无回答




相关问题
In SSAS, can parent-child DATAMEMBER name be customised

In a parent-child dimension in SSAS, the datamember is automatically named the same as the parent. E.g. Division X Risk Register Division X Risk Register Department A Risk Register Department B ...

Adding a Total column to MDX

I have the following query that gives me an extract (I am putting this into a CSV from my cube). I want to show the Total of all NRx in a column as the first column NRx and the rest of the NRx ...

using colors in calculated member

Im using this query in MDX for a calculate measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption this will bring me this result Dimension1 ...

Using colors with MDX calculated measure

I m using this query in MDX for a calculated measure topcount(nonempty([StatusPlanes].[Status].Status.members,[Measures].[Planes]),1)(0).member_caption This will bring me this result Dimension1 ...

Calculated Member for Cumulative Sum

First some background: I have the typical Date dimension (similar to the one in the Adventure Works cube) and an Account dimension. In my fact table I have daily transaction amounts for the accounts. ...

What is MDX and what is its use in SAP BPC

I would like to know more about "MDX" (Multidimensional Expressions). What is it? What is it used for? Why would you use it? Is it better than SQL? What is its use in SAP BPS (I haven t seen BPC, ...

热门标签