1621pooja
1621pooja

Reputation: 31

Dimensions dragged in filter pane do not slice scoped measures

A measure 'X' gets its value from different fact tables.Lets consider Time (Fiscal Week, Month)dimension and Channel dimension. For different combination of attributes in these two dimensions X will get its value from different tables as follows:

  1. Week + Channel - gets from table FactTrafficByWeekChannel
  2. Week - gets from table FactTrafficByWeek
  3. Month + Channel - gets from table FactTrafficByMonthChannel
  4. Month - gets from table FactTrafficByMonth

To achieve this I added these fact to cube and created a calculated measure and scope scripts to overwrite the scope. Following is the scope script statement:`

CALCULATE; 
CREATE MEMBER CURRENTCUBE.[Measures].[Y]
 AS (0), 
FORMAT_STRING = "Standard",
VISIBLE = 1;
Scope 
([Measures].[Y],[Dim Time].[Fiscal Week].[Fiscal Week].Members
 ) ; 
    This = [Measures].[X - Vw Fact Total Weekly Traffic];
End Scope ;
Scope 
([Measures].[Y],[Dim Time].[Fiscal Week].[Fiscal Week].Members,
[Dim Campaign].[Channel].[Channel].Members
 ) ; 
    This = [Measures].[X - Vw Fact Total Weekly Traffic By Channel];
End Scope ;
Scope 
 ([Measures].[Y],[Dim Time].[Fiscal Month].[Fiscal Month].Members
 ) ; 
    This = [Measures].[X - Vw Fact Monthly Traffic];
End Scope ;
Scope 
 ([Measures].[Y],[Dim Time].[Fiscal Month].[Fiscal Month].Members,
[Dim Channel].[Channel].[Channel].Members
 ) ; 
    This = [Measures].[X - Vw Fact Monthly Traffic By Channel];
End Scope ;

`

Above code works fine when corresponding dimension attributes are dragged in browsing pane but do not work when added to filter pane. Fiscal Week dimension dragged to browsing pane this works. But Fiscal Week dimension dragged to filter pane does not work. This is because attributes added to filter pane are added as sub-cube statements. Is there a way to achieve this when attributes are dragged to filter pane as well? Time dimension Attribute relationship (as asked by Greg) Adding Time dimension Attribute relationship image

Any help is highly appreciated. Thanks in advance

Upvotes: 2

Views: 790

Answers (1)

GregGalloway
GregGalloway

Reputation: 11625

One way is using dynamic named set as described in this post in the "Using dynamic sets to detect subselects" section.

Add this to the bottom of your existing MDX script:

Create dynamic named set CurrentCube.[SelectedWeeks] as [Dim Time].[Fiscal Week].[Fiscal Week].Members;

Scope 
 ([Measures].[Y],[Dim Time].[Fiscal Month].[All],
[Dim Time].[Fiscal Week].[All],
[Dim Channel].[Channel].[All]
 ) ; 
    This = iif(SelectedWeeks.Count<[Dim Time].[Fiscal Week].[Fiscal Week].Members.Count,[Measures].[X - Vw Fact Total Weekly Traffic],0);
End Scope ;

But the problem with that approach is that it is going to get totally out of control checking all the permutations of single select on channel vs multi select on week, etc. And it will likely be slow.

Instead I would recommend removing the Create Member statement for Y from your MDX script and adding a new measure to your "by channel by week" measure group. Call the new physical measure Y and make it a Sum and connect it to a new SQL column that returns 0 on every row. This is just a placeholder measure you will do scoped assignments against. Why physical? When you make a scoped assignment on a physical measure at the channel level for example that assignment aggregates up. (Assignments to calc measures don't aggregate up.) This helps solve the multiselect issue. You assign at the channel level for example and then the All channel number is correct even under multiselect.

That being said, I am not optimistic you will be able to figure out the correct order of scoped assignments so that all 4 of your measures show up where you want with proper multiselect handling. But feel free to try.

One tip is to use Freeze([Measures].[Y], [Dim Time].[Fiscal Month].[All]) after one scoped assignment to months if you are happy with that portion of the cube but find subsequent scoped assignments are changing parts you were happy with.

If you need further help include a screenshot of the Attribute Relationships tab for Dim Time.

Upvotes: 1

Related Questions