Saturday, February 25, 2012

Cube Partition

How do you slice a Cube Partition, if you want it to slice by "less than" instead of "equal to"? Analysis Services does not give you a choice.
Example: Time.FiscalYear AllTime.FY2005

Unfortunately, it looks like it can't be done without explicitly naming all the members included in the "less than" slice. For instance, if you wanted "less than" 2003, generally in MDX you'd just say {null:[Date].[Calendar Year].&[2003]}. But, for reasons I'll explain below, it doesn't appear that SSAS allows such an expression as the slice for a partition. Instead, you have to manually list all the members: {[Date].[Calendar Year].&[2001],[Date].[Calendar Year].&[2002],[Date].[Calendar Year].&[2003]}

If I understand this correctly, the "slice" for a partition has to be a string which resolves to a set. The way SSAS resolves it to a set is by running it through StrToSet("your slice",CONSTRAINED). The CONSTRAINED parameter tells it to only accept a simple set of explicitly named members. So StrToSet("{null:[Date].[Calendar Year].&[2003]}",CONSTRAINED) blows up during processing with the following error: "Errors in the OLAP storage engine: The restrictions imposed on partition slice where violated."

Though that's not a very good error message, I think that's what's happening because the following MDX query blows up:

select StrToSet("{null:[Date].[Calendar Year].&[2003]}",CONSTRAINED) on 0
from [Adventure Works]

One problem is that when you do a syntax check in Visual Studio when you're constructing the partition slice, it says it checks out fine... I've reported this as a bug:
https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=155391

Just as reference on where I got my info...

Info on what the Slice property of a partition allows (i.e. only something that works with StrToSet and CONSTRAINED):
http://msdn2.microsoft.com/en-us/library/microsoft.analysisservices.partition.slice(d=ide).aspx

Info on how the CONSTRAINED parameter works:
http://cwebbbi.spaces.msn.com/blog/cns!7B84B0F2C239489A!488.entry

No comments:

Post a Comment