Showing posts with label based. Show all posts
Showing posts with label based. Show all posts

Friday, March 23, 2012

How to reflect the equivalent of the relational IN operator in MDX

I need to filter a set, based in another attribute hierarchy.

So I am looking for something like

filter(Time.Months.children , Time.Months.currentmember.label in ({Timen.MonthName.Children})

The list is generated dinamycally, so the OR approach wouldn't work (unless I write 12 expressions.

Any ideas ?

Thank you

Alejandro Leguizamo

SQL Server MVP

Could you give an example with data, to help clarify? If this is a case where dimensions [Time] and [Timen] have identical structure (eg: role-playing dimensions like Date and ShipDate in Adventure Works), and you want the set in [Time].[Months] hierarchy, equivalent to some set in [Timen].[Months], then LinkMember() may work, like:

Generate([TimenSet], {LinkMember([Timen].[Month].CurrentMember, [Time].[Month])})

Wednesday, March 7, 2012

How to read a package variable in a custom component?

What I tried, based on something I found in Jamies blog:

IDTSVariables90 vars = null;
this.VariableDispenser.GetVariables(out vars);

However the vars stays empty, while I have 3 user variables defined. I saw in the documentation that one should not use 'VariableDispenser' since it is for internal use. But is there a better way, like in a script task, you just do
Dts.Variables("BatchID") .

Youre input is appreciated,
HenkPlease note the additional comments in the BOL topic on the Variable Dispenser property of the PipelineComponent base class. (The HTML always suffers when being copied and pasted, see below.) Can you try locking the variable first?
--

Remarks

The VariableDispenser is used to read and write variables in the package that contains the component. Before reading or writing a variable, it must be locked using one of the following methods; LockForRead, LockForWrite, LockOneForRead, or LockOneForWrite. After the variables are locked using the dispenser, they are available through the IDTSVariables90 interface.


Example

The following example demonstrates how to use the VariableDispenser to lock a single variable, and multiple variables.

C# Copy Code // Lock two variables, and then retrieve them by calling GetVariables. IDTSVariables90 variables = null; VariableDispenser.LockForRead("variable1"); VariableDispenser.LockForRead("variable2"); VariableDispenser.GetVariables(ref variables); object variable1 = variables[0].Value; object variable2 = variables[1].Value; // Retrieve a single variable. IDTSVariables90 variables = null; VariableDispenser.LockOneForRead("variable1", ref variables); object variable1 = variables[0].Value;

|||Thanks Douglas!