简体   繁体   中英

How do I filter a dimension based on current level of another dimension?

I'm trying to model "Same Store" sales in my cube.

I have a standard Date dimension with a Fiscal calendar.

I have a Location dimension with my stores. There are attributes for each store that specify a Year, Period, Quarter, and Week that indicates when a given store should be included in a report.

I'm thinking the route I want to take is a dynamic named set, but I could be wrong.

Basically I want to look at Net Sales for any given time frame, and have only Same Store sales show up. If I'm looking at the Year level, it needs to check the Year attribute. If I'm looking at the Quarter level, it needs to check the Quarter attribute.

How do I write my filter based on the level of the Date dimension? Can I have a Named Set of SameStores that contains all this logic?

EDIT: Additional info requested by @Prabhash Jha

Here is the view I want to look at - but I'm hoping there is a way to make this dynamic enough to handle any date calculations.

                  2012         2013
Store 1            1.2          1.3
Store 2             --          1.6
Store 3            1.3          2.1

At this level, Store 2 has a value of "2013" for SameStoreStartYear.

If I drill in to 2013:

                Q1          Q2         Q3
Store 1        0.2         0.3        0.5       
Store 2         --          --         .4
Store 3        0.2         0.3        0.5

At this level, Store 2 has a value of "3" for SameStoreStartMonth.

It continues like this down to Week level.

I've written some MDX to get me the set of stores that should be included relative to Date.Fiscal.currentmember, but only comparing at the year level. Was working on making it relative to drill level as well on Date.Fiscal hierarchy.

I had it as a named set, but it's using tuples from and the Named Set doesn't appear in the cube - I believe this is because it uses multiple Hierarchies and it doesn't know where to put it.

Here is my MDX so far:

select
filter(
([Date].[Fiscal].[Fiscal Year], [Location].[Store].[Store]), 
[Location].[SameStoreYearBegin].currentmember.properties("Key") 
    <= [Date].[Fiscal].currentmember.properties("Key"))
on 0
from Sales

Can you please clarify what you mean by "look at Net Sales for any given time frame, and have only Same Store sales show up" ? can you prepare some mockup for your current and expected results ?

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