简体   繁体   中英

Have to make Calculated Measure NULL for the starting year of a dimension in SSAS Cube

I have a cube that maintains 4 years of data(Say 2014 to 2017(till now)). I have two calculate measure in which i have to make NULL for year 2014. Till now we are using SCOPE and making it NULL.

For example, below is the existing code for a calculated Measure to become NULL for year 2014.

SCOPE (DESCENDANTS([Calendar_Date].[Calendar_Date].[2014]));                    
    [Measures].[Policy Retention Rate] = NULL;           
END SCOPE;

Calendar_Date is a dimension and having only one Hierarchy "Calendar_Date".

Every year we have to change the value which is passed in scope. We have to change it to 2015 next year which is causing manual work. So i have to automate it. Kindly help me with this.

You can generate year dynamically. For example, get a member 3 years ago:

StrToMember('[Calendar_Date].[Calendar_Date].&[' + Format(Now(),'yyyy') + ']').Lag(3)

However I'm not sure if it's possible to use that within SCOPE statement.

PS: I'd remove the deprecated partitions on your DWH instead of MDXing your data.

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