简体   繁体   中英

Converting dimension attribute to measure

I have to multiply some measure by value from dimension attribute.

I'm trying to make regular measure from this attribute and then i would can multiply

my code is:

CREATE MEMBER CURRENTCUBE.[Measures].[Formulaa]
 AS 
(
   [DIM RESOURCE].[Formula].Member_Value 
),
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'x'  ;  

CREATE MEMBER CURRENTCUBE.[Measures].[Formulaaa]
 AS 
(
   [Measures].[Formulaa] * [Measures].[Line Quantity In]     
),
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'x'  ;  

and it's working until i have in my browser (or query) [DIM RESOURCE].[Formula] attribute

But, when i remove it - i'm getting in [Measures].[Formulaa] the All value

So my question is: What i should do to avoid browsing this attribute?

First of all, you should know that in absence of a scope, it is the [ALL] member which a hierarchy is defaulted to. So, for your measure [Measures].[Formulaa] to work, you should be having a member from [DIM RESOURCE].[Formula] in your slicer or one of the axes.

Secondly, could you try replacing

[DIM RESOURCE].[Formula].Member_Value

with

[DIM RESOURCE].[Formula].CURRENTMEMBER.Member_Value ? The CURRENTMEMBER picks up the member in [DIM RESOURCE].[Formula] hierarchy which is currently in scope.

EDIT Keep the definitions as it is, but change the query as below:

SELECT 
    { 
        [Measures].[Line Quantity In], 
        [Measures].[Quantity In], 
        [Measures].[Formulaa] 
    } ON COLUMNS, 

    { 
        [DIM RESOURCE].[Formula].CHILDREN
    } ON ROWS 

FROM [CMR]

There are two ways of setting scope. You can either slice the cube by setting a member on the filter axis/sub-select OR you can specify the members on either of the axes. But you can't have unrelated in different axis and at the same time expect the measure value to change. That doesn't make sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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