简体   繁体   English

如何在Pentaho XML模式中使用CalculatedMember(尺寸,不测量)?

[英]How can i use CalculatedMember (dimension, not measure) in Pentaho xml schema?

I have this MDX query: 我有这个MDX查询:

WITH 
  MEMBER [CLIENT].[WITHOUT CLIENT X] AS 
    '[CLIENT].[All CLIENTs] - [CLIENT].[CLIENT X]' 
SELECT 
  [Measures].[Sales] ON COLUMNS
 ,{[STORE].[All STOREs].Children} ON ROWS
FROM [Sales]
WHERE 
  CrossJoin
  (
    {[YEAR].[2015]}
   ,{[CLIENT].[WITHOUT CLIENT X]}
  );

This query return corect result (All stores sales without [CLIENT].[CLIENT X] ). 该查询返回corect结果(所有商店都没有[CLIENT]。[CLIENT X]的销售 )。

Now, I want to use this calculated member ( [CLIENT].[WITHOUT CLIENT X] ) in Saiku, OpenI, BTable or Pivot4J as a normal dimension or something like this. 现在,我想在Saiku,OpenI,BTable或Pivot4J中使用此计算所得的成员( [CLIENT]。[WITHOUT CLIENT X] )作为常规尺寸或类似尺寸。

For this i added in schema.xml: 为此,我在schema.xml中添加了:

<CalculatedMember name="WITHOUT CLIENT X" 
 formula="([CLIENT].[All CLIENTs] - [CLIENT].[CLIENT X])" hierarchy="CLIENT" parent="CLIENT" visible="true"></CalculatedMember>

If i run: 如果我运行:

 Select [Measures].[Sales] on COLUMNS,
 {[STORE].[All STOREs].Children} ON ROWS
 from [Sales]
 WHERE CrossJoin({[YEAR].[2015]}, {[CLIENT].[WITHOUT CLIENT X]})

the result returned is corect, but i can't see this dimension [CLIENT].[WITHOUT CLIENT X]. 返回的结果是corect,但我看不到此尺寸[客户]。[没有客户X]。

In Saiku, OpenI or Pivot4J i can't find this dimension. 在Saiku,OpenI或Pivot4J中,我找不到此尺寸。 BTable get this dimension as MEASURES because of CDA (/api/olap/getCubeStructure) and result is this: 由于CDA(/ api / olap / getCubeStructure),BTable将此维度作为MEASURES获取,结果是:

 {
    "type": "measure",
    "name": "WITHOUT CLIENT X",
    "caption": "WITHOUT CLIENT X]",
    "qualifiedName": "[CLIENT].[CLIENT X]",
    "memberType": "FORMULA"
  }

but is useless because I can't use in filter. 但没用,因为我不能在过滤器中使用。

Do you have same answers? 你有同样的答案吗?

Posible questions: 可能的问题:

  1. Why u use member and not named set? 为什么您使用成员而不是命名集?

Because dimension CLIENT it's huge (more than 50000) query with member run in 1 sec and with set in more than 5 minutes 由于维度CLIENT的查询量很大(超过50000),成员运行时间为1秒,而设置时间为5分钟以上

  1. why don't use EXCEPT? 为什么不使用EXCEPT?

Same as 1. 与1相同

  1. why not use just mdx query? 为什么不只使用mdx查询?

Because final report is for non-tehnic and they want to change this filter. 因为最终报告是针对非技术性的,所以他们想更改此过滤器。

UPDATE INFO 更新信息

I renamed [CLIENT].[WITHOUT_this_CLIENT] with [CLIENT].[WITHOUT CLIENT X] and [CLIENT].[My Special Client] with *[CLIENT].[CLIENT X]*to avoid some confusion. 我将[CLIENT]重命名为[CLIENT]。[WITHOUT_this_CLIENT]重命名为[ WITHOUT CLIENT X][CLIENT]。[My Special Client]重命名为* [CLIENT]。[CLIENT X] *是为了避免混淆。

I want to filter a level in this way: add all members (CLIENT) except one ( CLIENT X ). 我想以这种方式过滤级别:添加除一个( CLIENT X )以外的所有成员(CLIENT)。

The result returned is corect when i use mdx query, because GUI OLAP clients cant read my xml schema. 当我使用mdx查询时, 返回的结果是corect ,因为GUI OLAP客户端无法读取我的xml模式。

I don't know where is my error. 我不知道我的错误在哪里。

Thank you, Geo 谢谢Geo

SOLVED 解决了

For what I want (filtering one element from a big list) the answer is this: 对于我想要的(从一个大列表中过滤一个元素),答案是这样的:

I created another dimension, which is used just for filter. 我创建了另一个维度,该维度仅用于过滤器。

    <Dimension type="StandardDimension" visible="true" highCardinality="false" name="CLIENT X">
    <Hierarchy visible="true" hasAll="true">
      <Table name="SALES" schema="SALES" />
      <Level name="CLIENT X" visible="true" column="CLIENT" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
        <KeyExpression>
          <SQL dialect="oracle">
            <![CDATA[CASE WHEN CLIENT =  'CLIENT X'  THEN  'CLIENT X' ELSE 'WITHOUT CLIENT X' END]]>
          </SQL>
        </KeyExpression>
      </Level>
    </Hierarchy>
  </Dimension>

You're not defining your member correctly. 您没有正确定义成员。 ie. 即。 The parent member must be the fully qualified name of the parent of the newly created member, not the level's name. 父级成员必须是新创建的成员的父级的完全限定名称,而不是级别的名称。 Read this carefully and you'll figure it out. 仔细阅读此内容 ,您会发现答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM