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

Monday, March 26, 2012

Member based security & aggregations

Performance question:

We are using member based security, which restricts at the lowest level of our hierarchies. When a user connects to AS we are using the CustomData attribute of the connection string, which passes in a user ID which is resolved to a keyset. If we are quering a few levels higher than the lowest level, and an aggregation has been created at the level being queried, does the engine "crawl" the hierarchy to determine if it can use the aggregation (provided the user has access to all lowest level members), or will abandon the aggregation and sum them up since it is already touching the lowest level?

If anyone has any insight, it would be much appreciated.

Thank you in advance,

John Hennesey

Depends on how you set the Visual Totals attribute on the dimension attribute permission. If it is set to False, which is the default, your totals will reflect all child values whether or not the child is available per the security setting. This helps to keep performance high in the cube and in most situations does not cause problems so long as end-users are aware of why their totals do not match the values for the members visible to them.

If you set the property to true, totals will reflect just those members available to the end user.

B.

|||

And to continue on from Bryan, visual totals is known to reduce performance. I don't know if it actually checks if a given user has access to all the children of a given member and then uses the higher level member, or if it will always add up the applicable members of the allowed set. I think it might be intersecting the allowed set and adding up the results, but I don't know for sure, this is just a guess.

Either way you are better to set your security at the highest level that you can. If you want a person to see all the cities in a given state, given them access to the state member rather than to an explicit list of cities.

|||

Bryan / Darren -

Thank you both for your quick responses - certainly not what I was expecting (or hoping for); it is a bummer because our security is set at the lowest level, but I completely understand why it works this way. Oh well. Smile

Thanks

John Hennesey

Monday, March 19, 2012

Me!Value in matrix subtotal

G'day all,
Trying to set a property, for instance foreground color, based on Me!Value expression in a matric subtotal with an expression like:
=IIf(Me.Value < 0, "Red", "Black")
produces the following error:
The color expression for the matrix â'matrix1â' contains an error: [BC30456] 'Value' is not a member of 'ReportExprHostImpl.EH_matrix1.EH_MatrixDynamicGroup_...
jez_UK posted a similar question which is unanswered on July 14th, but my question is on Me!Value was different enough to warrant a new post.
Thanks in advance,
Thomas WilliamsI assume you clicked on the green triangle for the subtotal properties, and
modified the color expression for the subtotal. This won't work, because
every matrix cell is just a "container" for multiple reportitems (in your
case the matrix cell probably just contains one textbox). Only textboxes
would support Me.Value but not rectangles, etc. Therefore the compilation of
the expression results in an error.
You have to do this using an expression in textboxes of the matrix data
cells (assuming you have one column/row grouping called matrix1_ProdCat):
=iif(InScope("matrix1_ProdCat"), "Green", iif(Me.Value < 0, "Red", "Black"))
The expression above would do two things:
* regular matrix cell (which are in the scope of the matrix1_ProdCat
grouping) will have a green color
* subtotal matrix cells (which are not in the scope of the grouping) will
have red or black color based on the current textbox value.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Thomas Williams" <thomasswilliams@.hotmail.com> wrote in message
news:AE48347D-440C-4E91-97EC-234F464F871B@.microsoft.com...
> G'day all,
> Trying to set a property, for instance foreground color, based on Me!Value
expression in a matric subtotal with an expression like:
> =IIf(Me.Value < 0, "Red", "Black")
> produces the following error:
> The color expression for the matrix 'matrix1' contains an error: [BC30456]
'Value' is not a member of
'ReportExprHostImpl.EH_matrix1.EH_MatrixDynamicGroup_...
> jez_UK posted a similar question which is unanswered on July 14th, but my
question is on Me!Value was different enough to warrant a new post.
> Thanks in advance,
> Thomas Williams|||Hi Robert, thanks for the reply, now I've got to figure out the scope of my groupings (3 row groups, 1 column group) and create an "IIf" statement to cover them.
Thanks again mate!
"Robert Bruckner [MSFT]" wrote:
> I assume you clicked on the green triangle for the subtotal properties, and
> modified the color expression for the subtotal. This won't work, because
> every matrix cell is just a "container" for multiple reportitems (in your
> case the matrix cell probably just contains one textbox). Only textboxes
> would support Me.Value but not rectangles, etc. Therefore the compilation of
> the expression results in an error.
> You have to do this using an expression in textboxes of the matrix data
> cells (assuming you have one column/row grouping called matrix1_ProdCat):
> =iif(InScope("matrix1_ProdCat"), "Green", iif(Me.Value < 0, "Red", "Black"))
> The expression above would do two things:
> * regular matrix cell (which are in the scope of the matrix1_ProdCat
> grouping) will have a green color
> * subtotal matrix cells (which are not in the scope of the grouping) will
> have red or black color based on the current textbox value.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Thomas Williams" <thomasswilliams@.hotmail.com> wrote in message
> news:AE48347D-440C-4E91-97EC-234F464F871B@.microsoft.com...
> > G'day all,
> >
> > Trying to set a property, for instance foreground color, based on Me!Value
> expression in a matric subtotal with an expression like:
> > =IIf(Me.Value < 0, "Red", "Black")
> >
> > produces the following error:
> > The color expression for the matrix 'matrix1' contains an error: [BC30456]
> 'Value' is not a member of
> 'ReportExprHostImpl.EH_matrix1.EH_MatrixDynamicGroup_...
> >
> > jez_UK posted a similar question which is unanswered on July 14th, but my
> question is on Me!Value was different enough to warrant a new post.
> >
> > Thanks in advance,
> >
> > Thomas Williams
>
>|||I was redirected to this post from another. I am still having problems, though this post has clarified the Why and the What. I am at a loss for How.
What does "You have to do this using an expression in textboxes of the matrix data cells" mean? I take that to mean I need to make a textbox somewhere (I cannot use the provided subtotal matrix cell). Do you mean I have to delete the subtotal (and corresponding text box) and somehow manually add a textbox to the group and write an expression to get the value(the subtotal) and an expression to change the text color? Any help is greatly appreciated - I am spinning on this right now.
Thanks.
"Robert Bruckner [MSFT]" wrote:
> I assume you clicked on the green triangle for the subtotal properties, and
> modified the color expression for the subtotal. This won't work, because
> every matrix cell is just a "container" for multiple reportitems (in your
> case the matrix cell probably just contains one textbox). Only textboxes
> would support Me.Value but not rectangles, etc. Therefore the compilation of
> the expression results in an error.
> You have to do this using an expression in textboxes of the matrix data
> cells (assuming you have one column/row grouping called matrix1_ProdCat):
> =iif(InScope("matrix1_ProdCat"), "Green", iif(Me.Value < 0, "Red", "Black"))
> The expression above would do two things:
> * regular matrix cell (which are in the scope of the matrix1_ProdCat
> grouping) will have a green color
> * subtotal matrix cells (which are not in the scope of the grouping) will
> have red or black color based on the current textbox value.
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "Thomas Williams" <thomasswilliams@.hotmail.com> wrote in message
> news:AE48347D-440C-4E91-97EC-234F464F871B@.microsoft.com...
> > G'day all,
> >
> > Trying to set a property, for instance foreground color, based on Me!Value
> expression in a matric subtotal with an expression like:
> > =IIf(Me.Value < 0, "Red", "Black")
> >
> > produces the following error:
> > The color expression for the matrix 'matrix1' contains an error: [BC30456]
> 'Value' is not a member of
> 'ReportExprHostImpl.EH_matrix1.EH_MatrixDynamicGroup_...
> >
> > jez_UK posted a similar question which is unanswered on July 14th, but my
> question is on Me!Value was different enough to warrant a new post.
> >
> > Thanks in advance,
> >
> > Thomas Williams
>
>|||Don't delete the subtotal. However, instead of clicking on the green
triangle in the matrix heading, you click on the actual matrix data cell
which will show your data (most likely the matrix cell contains a textbox in
your case). The matrix cell probably contains an expression like
=Sum(Fields!Sales.Value)
For the conditional formatting of the cell content you will then use an
expression as outlined below:
=iif(InScope("matrix1_ProdCat"), "Green", iif(Me.Value < 0, "Red", "Black"))
If you have multiple row/column groupings in the matrix you will need to
take them into account when using the InScope function to determine if the
cell at runtime is a "subtotal cell" or a regular "data cell".
More information on InScope is available at:
http://msdn.microsoft.com/library/en-us/RSCREATE/htm/rcr_creating_expressions_v1_0jmt.asp
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Getting started and liking it" <Getting started and liking
it@.discussions.microsoft.com> wrote in message
news:6A6F92A4-59AA-4B90-8A5A-433E85B3A8B6@.microsoft.com...
> I was redirected to this post from another. I am still having problems,
though this post has clarified the Why and the What. I am at a loss for How.
> What does "You have to do this using an expression in textboxes of the
matrix data cells" mean? I take that to mean I need to make a textbox
somewhere (I cannot use the provided subtotal matrix cell). Do you mean I
have to delete the subtotal (and corresponding text box) and somehow
manually add a textbox to the group and write an expression to get the
value(the subtotal) and an expression to change the text color? Any help is
greatly appreciated - I am spinning on this right now.
> Thanks.
> "Robert Bruckner [MSFT]" wrote:
> > I assume you clicked on the green triangle for the subtotal properties,
and
> > modified the color expression for the subtotal. This won't work, because
> > every matrix cell is just a "container" for multiple reportitems (in
your
> > case the matrix cell probably just contains one textbox). Only textboxes
> > would support Me.Value but not rectangles, etc. Therefore the
compilation of
> > the expression results in an error.
> >
> > You have to do this using an expression in textboxes of the matrix data
> > cells (assuming you have one column/row grouping called
matrix1_ProdCat):
> > =iif(InScope("matrix1_ProdCat"), "Green", iif(Me.Value < 0, "Red",
"Black"))
> >
> > The expression above would do two things:
> > * regular matrix cell (which are in the scope of the matrix1_ProdCat
> > grouping) will have a green color
> > * subtotal matrix cells (which are not in the scope of the grouping)
will
> > have red or black color based on the current textbox value.
> >
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
rights.
> >
> >
> > "Thomas Williams" <thomasswilliams@.hotmail.com> wrote in message
> > news:AE48347D-440C-4E91-97EC-234F464F871B@.microsoft.com...
> > > G'day all,
> > >
> > > Trying to set a property, for instance foreground color, based on
Me!Value
> > expression in a matric subtotal with an expression like:
> > > =IIf(Me.Value < 0, "Red", "Black")
> > >
> > > produces the following error:
> > > The color expression for the matrix 'matrix1' contains an error:
[BC30456]
> > 'Value' is not a member of
> > 'ReportExprHostImpl.EH_matrix1.EH_MatrixDynamicGroup_...
> > >
> > > jez_UK posted a similar question which is unanswered on July 14th, but
my
> > question is on Me!Value was different enough to warrant a new post.
> > >
> > > Thanks in advance,
> > >
> > > Thomas Williams
> >
> >
> >

Monday, March 12, 2012

MDX, dates and Calendar Control in Reporting services 2005

Hi,
I need to develop several reports in RS 2005 where the report
parameters are dates. The reports are based on a SQL Server 2005
Analysis Services Cube and consequently the reports need to be based
on MDX. My dates are formatted according to Swedish date standard. I
would like the users to pick the dates from a Calendar control.
(I have seen several smilar problems with dates, but all referring to
SQ statements, not MDX)
Here's my problem:
When I design my query in the Data tab of the report, I choose the
field that I want to use as a parameter (in this case a date) and tick
the checkbox indicating that I want a Report parameter created.
When I inspect the report in Preview, the date is not displayed in a
calendar, but instead as a tremendously long list. (Not good!) When I
look at the report parameter in Layout it has the datatype String.
- If I change the parameter to DateTime (in order to get a calendar),
I get a runtime error: "an error occurred during local report
processing. The property 'Valid Values' of report paramater
'KalenderDatum' doesn't have the expected type."
My question:
- What can I do to make Reporting Services understand that I want to
display dates?
- Can calendar controls be used with MDX at all'
- Is there someting I need to do in MDX to format my date as a
DateTime field?
- Does RS just not like Swedish' ;-)
Additional info:
- My cube is built on a staging database, and if I design a report
against that database with ordinary SQL statements using the same
DateTime field, I get a calendar control, and RS understands that I
want to display dates. Everything works fine.
- I have set the language property on my report to Swedish (the date
format being yyyy-mm-dd)
Please let me know if there is a workaround for this. Unfortunately
MDX is not exactly my second language either...
CarinaI had the same problem (but with US date formats). What you need to do is on
the "Data" tab in your RS project, change the MDX query to an expression by
putting an = there followed by your whole MDX query in double quotes. Then
concantenate in your parameter date fields. Here is an example of how I did
it for a range on [Start Date] based on 2 datetime parameters called
Begin_Date and End_Date. Note, be sure there are no control characters or
carriage returns in your MDX expression.
="SELECT NON EMPTY { [Measures].[Login Count]} ON COLUMNS, NON EMPTY {
[GroupUsers].[Application - Name].[Login Name].ALLMEMBERS * [Date].[Start
Date].&[" & Format(Parameters!Begin_Date.Value,"MM/dd/yyyy") &
"]:[Date].[Start Date].&[" & Format(Parameters!End_Date.Value,"MM/dd/yyyy") &
"] } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM
[MyCubeDataset])) CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR,
FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS"
I just set up regular Datetime report parameters for Begin_Date and End_Date
and added them to the dataset on the parameters tab. I formatted them into
the format I wanted inside the expression above because I needed the leading
zeroes for the date comparisons to work in MDX. Also, here is a link that
helped me:
http://msdn2.microsoft.com/en-us/library/aa902647(sql.80).aspx
Hope this helps.
"carina.jones@.sogeti.se" wrote:
> Hi,
> I need to develop several reports in RS 2005 where the report
> parameters are dates. The reports are based on a SQL Server 2005
> Analysis Services Cube and consequently the reports need to be based
> on MDX. My dates are formatted according to Swedish date standard. I
> would like the users to pick the dates from a Calendar control.
> (I have seen several smilar problems with dates, but all referring to
> SQ statements, not MDX)
> Here's my problem:
> When I design my query in the Data tab of the report, I choose the
> field that I want to use as a parameter (in this case a date) and tick
> the checkbox indicating that I want a Report parameter created.
> When I inspect the report in Preview, the date is not displayed in a
> calendar, but instead as a tremendously long list. (Not good!) When I
> look at the report parameter in Layout it has the datatype String.
> - If I change the parameter to DateTime (in order to get a calendar),
> I get a runtime error: "an error occurred during local report
> processing. The property 'Valid Values' of report paramater
> 'KalenderDatum' doesn't have the expected type."
> My question:
> - What can I do to make Reporting Services understand that I want to
> display dates?
> - Can calendar controls be used with MDX at all'
> - Is there someting I need to do in MDX to format my date as a
> DateTime field?
> - Does RS just not like Swedish' ;-)
> Additional info:
> - My cube is built on a staging database, and if I design a report
> against that database with ordinary SQL statements using the same
> DateTime field, I get a calendar control, and RS understands that I
> want to display dates. Everything works fine.
> - I have set the language property on my report to Swedish (the date
> format being yyyy-mm-dd)
>
> Please let me know if there is a workaround for this. Unfortunately
> MDX is not exactly my second language either...
> Carina
>|||Thank you so much for your input! With your help and the explanation
below I did figure it out :-). I'm a happy camper!
/Carina
In short (found this explanation on another site):
1. Develop the report.
2. Change the Data Type of the date parameters to DateTime, and set
Available Values to Non-queried.
3. On the Data tab, edit the cube's Dataset (click on the ... button).
4. Click on the Parameters tab of the Dataset dialog box. Replace the
Value of the date parameters with ="[Dimension].[Member].&[" +
Format(CDate(Parameters!ParameterName.Value), "yyyy-MM-ddT00:00:00") +
"]" where [Dimension].[Member] and ParameterName are the dimensions
and parameter names of your particular cube. Depending on how your
dimension is set up, you may also need to change the format of the
date.
5. There is no need to change the MDX of the query.

Friday, March 9, 2012

MDX Ranking Question

Hi

We are trying to create a Ranking of a dimension based on multiple different measures. An example would be to rank the Sales Consultant by Num Sales, Total Sales and Num Customers.

In SQL, I would create three different temp tables, with the Sales Consultant, Measure and Ranking for each different measure. Then you could join these results together and generate the final ranking based on this result set.

Now the problem we are having is doing this in MDX. You can only order by one of the measures in any result set. Any way I look at this, it looks to be a multi step process to create this data. The only way I can think that this might work is to create a stored proc, but then this will limit the users ability to slice data by all the dimensions.

Are there any ideas on how we can do this that I have missed?

Thanks

Michael

Hi Michael,

Here's a sample Adventure Works ranking query - could you give more details, with examples, of your scenario?

With

Set [OrderedProducts] as

Order([Product].[Category].[Category]

* {[Measures].[Order Quantity]},

[Measures].[Order Quantity], BDESC)

+ Order([Product].[Category].[Category]

* {[Measures].[Sales Amount]},

[Measures].[Sales Amount], BDESC)

+ Order([Product].[Category].[Category]

* {[Measures].[Total Product Cost]},

[Measures].[Total Product Cost], BDESC)

Member [Measures].[QuantityRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[Order Quantity]),

Exists([OrderedProducts],

{[Measures].[Order Quantity]}))

Member [Measures].[SalesRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[Sales Amount]),

Exists([OrderedProducts],

{[Measures].[Sales Amount]}))

Member [Measures].[CostRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[Total Product Cost]),

Exists([OrderedProducts],

{[Measures].[Total Product Cost]}))

select

{[Measures].[Order Quantity],

[Measures].[QuantityRank],

[Measures].[Sales Amount],

[Measures].[SalesRank],

[Measures].[Total Product Cost],

[Measures].[CostRank]} on 0,

Extract(Exists([OrderedProducts],

{[Measures].[Order Quantity]}),

[Product].[Category]) on 1

from [Adventure Works]

--

Order Quantity QuantityRank Sales Amount SalesRank Total Product Cost CostRank
Bikes 90,220 1 $94,620,526.21 1 $84,105,429.60 1
Clothing 73,598 2 $2,117,613.45 3 $1,748,777.45 3
Accessories 61,931 3 $1,272,057.89 4 $637,590.73 4
Components 49,027 4 $11,799,076.66 2 $10,766,110.18 2

|||

Hi

Thanks very much!!!! This just shows how far I have to go to understand MDX...

I took your query and expanded it to give what we were looking for:

With

Set [OrderedProducts] as

Order([Product].[Category].[Category]

* {[Measures].[Order Quantity]},

[Measures].[Order Quantity], BDESC)

+ Order([Product].[Category].[Category]

* {[Measures].[Sales Amount]},

[Measures].[Sales Amount], BDESC)

+ Order([Product].[Category].[Category]

* {[Measures].[Total Product Cost]},

[Measures].[Total Product Cost], BDESC)

Member [Measures].[QuantityRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[Order Quantity]),

Exists([OrderedProducts],

{[Measures].[Order Quantity]}))

Member [Measures].[SalesRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[Sales Amount]),

Exists([OrderedProducts],

{[Measures].[Sales Amount]}))

Member [Measures].[CostRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[Total Product Cost]),

Exists([OrderedProducts],

{[Measures].[Total Product Cost]}))

Member [Measures].[OverallActivity] as

1/(

(1/[Measures].[QuantityRank])^2 +

(1/[Measures].[SalesRank])^2 +

(1/[Measures].[CostRank])^2

)

Set [OrderedActivity] as

Order([Product].[Category].[Category]

* {[Measures].[OverallActivity]},

[Measures].[OverallActivity], BASC)

Member [Measures].[ActivityRank] as

Rank(([Product].[Category].CurrentMember,

[Measures].[OverallActivity]),

Exists([OrderedActivity],

{[Measures].[OverallActivity]}))

select

{[Measures].[Order Quantity],

[Measures].[QuantityRank],

[Measures].[Sales Amount],

[Measures].[SalesRank],

[Measures].[Total Product Cost],

[Measures].[CostRank],

[Measures].[OverallActivity],

[Measures].[ActivityRank]} on 0,

Extract(Exists([OrderedProducts],

{[Measures].[Order Quantity]}),

[Product].[Category]) on 1

from [Adventure Works]

Which gives us the Overall ranking of the Product by these three rankings:

Order Quantity QuantityRank Sales Amount SalesRank Total Product Cost CostRank OverallActivity ActivityRank
Bikes 90,220 1 $94,620,526.21 1 $84,105,429.60 1 0.333333333333333 1
Clothing 73,598 2 $2,117,613.45 3 $1,748,777.45 3 2.11764705882353 3
Accessories 61,931 3 $1,272,057.89 4 $637,590.73 4 4.23529411764706 4
Components 49,027 4 $11,799,076.66 2 $10,766,110.18 2 1.77777777777778 2

Once again, Thanks for the help!!!!

|||

Hi

A further question to this. We are also wanting to make this ranking Time aware. Currently, you can only run the quesry for a specific time period (eg [dimDate].[Year].[2006]). If you try to create a crossjoin in the report to have all the above measures by 2005 and 2006, then the ranking does not work anymore. As far as I understand it, this will be the case as the Order Set does not know about the time dimension, and hasn't ordered the Products by Time.

So, how I see this is that I will need to add the time Dim to the order Set, but at what level. We would like to make this dynamic within the cube and would like the ranking to work in a year on year, quarter on quarter, month on month ...etc level. I would think that ordering by the lowest level of time (day in my case) might work, but would create a set that is extremely large.

Would this work, or is there a better way to do this?

Michael

|||

Hi Michael,

This is a common requirement, but it's beyond the ordered SQL temp table approach. You could use Rank() dynamically, as shown in the query below. But there might be a performance penalty - see this 2005 thread from the OLAP newsgroup:

With

Member [Measures].[QuantityRank] as

Rank([Product].[Category].CurrentMember,

[Product].[Category].[Category],

[Measures].[Order Quantity])

Member [Measures].[SalesRank] as

Rank([Product].[Category].CurrentMember,

[Product].[Category].[Category],

[Measures].[Sales Amount])

Member [Measures].[CostRank] as

Rank([Product].[Category].CurrentMember,

[Product].[Category].[Category],

[Measures].[Total Product Cost])

Member [Measures].[OverallActivity] as

1/(

(1/[Measures].[QuantityRank])^2 +

(1/[Measures].[SalesRank])^2 +

(1/[Measures].[CostRank])^2

)

Member [Measures].[ActivityRank] as

Rank([Product].[Category].CurrentMember,

[Product].[Category].[Category],

-[Measures].[OverallActivity])

select

{[Measures].[Order Quantity],

[Measures].[QuantityRank],

[Measures].[Sales Amount],

[Measures].[SalesRank],

[Measures].[Total Product Cost],

[Measures].[CostRank],

[Measures].[OverallActivity],

[Measures].[ActivityRank]} on 0,

[Date].[Calendar Year].[Calendar Year]

* [Product].[Category].[Category] on 1

from [Adventure Works]

|||Thanks for all the help! That is working fine, and is not too slow. It is not a commonly used calc so shouldn't pose a problem.

MDX question

Hi,

Here is my question.

For the last year special store sales amount, we only calculate sales amount based on special store lists in current selected date.

If a store in current date is not a special store then we do not include this store for last year sales amount (even if this store was special store in last year). This means we don't care about last year store status and we only identify the special store status of all stores according to the date we selected.

In the fact, I join the flag ( which represents a special store) and added one colum for special sales calcualtion. (flag * net sales). In the cube, Currnet speical sales are correct but I couldn't get correct last year specail sales amount.

Below is the calculation for last year specail store sales amount but the numbers do not match.

IIF(([Measures].[flag], [Date].[Fiscal Hierarchy].CurrentMember)=False,0,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

Please give me some comments.

Thanks in advance.

Boolean values as measures just don't work well. There probably would be a way to write the MDX calculation, but the performance would be really bad probably to the point of being unusable.

You could implement the flag as it's own dimension, but probably the best approach is to implement the store dimension as a slowly changing dimension. What you would be after is a type 2 changing dimension. If you are not aware of what this is, you are basically adding a new record to the store dimension when the value of the flag changes

Below is a simplified example, notice that "Store 1" has StoreID = 1 and StoreID = 3. It is often common to store effective dates against the records for slowly changing dimensions to make it easier to figure out which dimension record applies to a given fact record.

StoreID StoreName SpecialFlag

1 Store 1 False

2 Store 2 False

3 Store 1 True

Then when you insert facts you insert the StoreID that was effective for the date of the respective facts.

StoreID DateID SalesAmount

1 20060101 100

3 20070601 100

Using this technique you would be able to create a "Special Store" attribute in your store dimension and filter using that.

|||

Thanks for the reply. I think I didn't give you a right explanation.

I understand what you suggested but could you take a look at this one more time?

Below is the details how it looks like :

Selected date : 20070101

Last year date : 20060101

Sales Fact

ID Store_key Date Sales

1 store 1 20070101 100.00

2 store 2 20070101 150.00

3 store 3 20070101 100.00

4 store 1 20060101 30.00

5 store 2 20060101 30.00

6 store 3 20060101 30.00

There is an anther fact table which has a flag.

Special_Store Fact

Special_Store_key Store_key Date Key SS_flag

1 store 1 20070101 True

2 store 1 20060101 False

3 store 2 20070101 False

4 store 2 20060101 True

5 store 3 20070101 False

6 store 3 20060101 True

Now I joined this 2 Fact to add Specail Store Sales into the Sales Fact

ID Store_key Date Sales SS_flag SS_Sales (SS flag * Sales)

1 store 1 20070101 100.00 True 100.00

2 store 2 20070101 150.00 False 0.00

3 store 3 20070101 100.00 True 100.00

4 store 1 20060101 30.00 False 0.00

5 store 2 20060101 30.00 True 30.00

6 store 3 20060101 30.00 True 30.00

From this data,

we calulate SS sales amount and the total is 130.00 which is not a problem to calculate in the cube.

My problem is that for the last year SS sales amount with time calculation we developed inside the cube,

time calculation sums up all SS_Sales, so last year total is 60.00.

But from the selected date , we do not consider last year store status. We only care current Special Store and From this list we calculate last year value. So, in this data, we need to get 30 (excluding store 2 since store 2 is not special store in the selected date 20070101).

As you mentioned, if boolean value does not work properly and affects performance then how can I approach in this situation? Any Suggestions?

Please let me know.

Thanks.

|||

I am pretty sure that my original suggestion of not adding this flag to the fact table and implementing a slowly changing dimension would work. But possibly a simpler solution might be to insert NULL insead of 0.00 into the SS_Sales measure and then do something like the following, which basically checks if there is a value for [Special Sales] in the current period.

IIF(IsEmpty({([Measures].[Special Sales], [Date].[Fiscal Hierarchy].CurrentMember)}),NULL,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

The only problem with this is that, if you have a hierarchy over the stores so that they roll up into groups of some sort then you will get incorrect results at the higher levels. If any store in the group was "sepcial" last year the value for the entire group would be included

Which would mean that you might have to do something like the following to force this expression to be evaluated over individual store members.

SUM( EXISTING [Store].[Store].[Store].Members ,

IIF(IsEmpty({([Measures].[Special Sales], [Date].[Fiscal Hierarchy].CurrentMember)}),NULL,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

)|||

There seems to be some inconsistency in the sample data: Store 3, 20070101 is shown as a special sale in the joined fact table, but not in Special_Store_Fact - I assume that is just a typo?

Anyway, since SS_Flag is already a field in the joined fact table, another approach would to create a simple true/false dimension like [Special Flag]. Then the MDX expressions could be:

For current year [Special Sales]:

([Special Flag].[SL_Flag].[True], [Measures].[Sales])

And for previous year [Special Sales]:

Sum(NonEmpty([Store].[Store].[Store].Members,

([Special Flag].[SL_Flag].[True], [Measures].[Sales])),

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

|||

That's probably a reasonable compromise and would be relatively easy to implement.

The only comment I would make is that modelling changing attributes in this matter should be the exception, not the rule. You would not want to take this to the extreme and end up with a cube that has lots of small dimensions as it increases the size of the aggregations and indexes which will reduce performance.

|||

Hi,

It's been a quite long time since you posted this.

Now, we have some changes regarding this special store's calculation.

Previously, we only select the current special store list, and for the last year value, we use current lists of special stores and if any store which was not special store in parallel period then we excluded it from the calculation.

I've tried this MDX into the cube and current year value works perfectly, but last year value doesn't work properly.

MDX for the last year :

Sum(NonEmpty([Store].[Store Hierarchy].currentmember,

([Special Flag].[SL_Flag].[True], [Measures].[Sales])),

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

> This mdx calculate all the last year value that store became a special in last year. it can't get the current special store lists.

But now, whether store was not a spcial store in last year, if store became a special store in selected date ( current) then we sum up all store's sale amount into the last year value.

below is the MDX for the last year:

([Special Flag].[SL_Flag].[True],

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

But when i browse the cube, it seems last year special flag is used for last year calculation. So, I can see all special store sales amount in last year. (not exclude store which is not a special store in current year)

I've tried to do different ways but still couldn't get any solutions yet.

It seems the MDX is something wrong.

If I want to use current special flag for the parallelperiod calculation how should I write MDX for that?

I think this logic makes sense to me but I don't know why it doesn't work.

I would appreciate if anybody can give me some comments.

Thanks.

MDX question

Hi,

Here is my question.

For the last year special store sales amount, we only calculate sales amount based on special store lists in current selected date.

If a store in current date is not a special store then we do not include this store for last year sales amount (even if this store was special store in last year). This means we don't care about last year store status and we only identify the special store status of all stores according to the date we selected.

In the fact, I join the flag ( which represents a special store) and added one colum for special sales calcualtion. (flag * net sales). In the cube, Currnet speical sales are correct but I couldn't get correct last year specail sales amount.

Below is the calculation for last year specail store sales amount but the numbers do not match.

IIF(([Measures].[flag], [Date].[Fiscal Hierarchy].CurrentMember)=False,0,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

Please give me some comments.

Thanks in advance.

Boolean values as measures just don't work well. There probably would be a way to write the MDX calculation, but the performance would be really bad probably to the point of being unusable.

You could implement the flag as it's own dimension, but probably the best approach is to implement the store dimension as a slowly changing dimension. What you would be after is a type 2 changing dimension. If you are not aware of what this is, you are basically adding a new record to the store dimension when the value of the flag changes

Below is a simplified example, notice that "Store 1" has StoreID = 1 and StoreID = 3. It is often common to store effective dates against the records for slowly changing dimensions to make it easier to figure out which dimension record applies to a given fact record.

StoreID StoreName SpecialFlag

1 Store 1 False

2 Store 2 False

3 Store 1 True

Then when you insert facts you insert the StoreID that was effective for the date of the respective facts.

StoreID DateID SalesAmount

1 20060101 100

3 20070601 100

Using this technique you would be able to create a "Special Store" attribute in your store dimension and filter using that.

|||

Thanks for the reply. I think I didn't give you a right explanation.

I understand what you suggested but could you take a look at this one more time?

Below is the details how it looks like :

Selected date : 20070101

Last year date : 20060101

Sales Fact

ID Store_key Date Sales

1 store 1 20070101 100.00

2 store 2 20070101 150.00

3 store 3 20070101 100.00

4 store 1 20060101 30.00

5 store 2 20060101 30.00

6 store 3 20060101 30.00

There is an anther fact table which has a flag.

Special_Store Fact

Special_Store_key Store_key Date Key SS_flag

1 store 1 20070101 True

2 store 1 20060101 False

3 store 2 20070101 False

4 store 2 20060101 True

5 store 3 20070101 False

6 store 3 20060101 True

Now I joined this 2 Fact to add Specail Store Sales into the Sales Fact

ID Store_key Date Sales SS_flag SS_Sales (SS flag * Sales)

1 store 1 20070101 100.00 True 100.00

2 store 2 20070101 150.00 False 0.00

3 store 3 20070101 100.00 True 100.00

4 store 1 20060101 30.00 False 0.00

5 store 2 20060101 30.00 True 30.00

6 store 3 20060101 30.00 True 30.00

From this data,

we calulate SS sales amount and the total is 130.00 which is not a problem to calculate in the cube.

My problem is that for the last year SS sales amount with time calculation we developed inside the cube,

time calculation sums up all SS_Sales, so last year total is 60.00.

But from the selected date , we do not consider last year store status. We only care current Special Store and From this list we calculate last year value. So, in this data, we need to get 30 (excluding store 2 since store 2 is not special store in the selected date 20070101).

As you mentioned, if boolean value does not work properly and affects performance then how can I approach in this situation? Any Suggestions?

Please let me know.

Thanks.

|||

I am pretty sure that my original suggestion of not adding this flag to the fact table and implementing a slowly changing dimension would work. But possibly a simpler solution might be to insert NULL insead of 0.00 into the SS_Sales measure and then do something like the following, which basically checks if there is a value for [Special Sales] in the current period.

IIF(IsEmpty({([Measures].[Special Sales], [Date].[Fiscal Hierarchy].CurrentMember)}),NULL,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

The only problem with this is that, if you have a hierarchy over the stores so that they roll up into groups of some sort then you will get incorrect results at the higher levels. If any store in the group was "sepcial" last year the value for the entire group would be included

Which would mean that you might have to do something like the following to force this expression to be evaluated over individual store members.

SUM( EXISTING [Store].[Store].[Store].Members ,

IIF(IsEmpty({([Measures].[Special Sales], [Date].[Fiscal Hierarchy].CurrentMember)}),NULL,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

)|||

There seems to be some inconsistency in the sample data: Store 3, 20070101 is shown as a special sale in the joined fact table, but not in Special_Store_Fact - I assume that is just a typo?

Anyway, since SS_Flag is already a field in the joined fact table, another approach would to create a simple true/false dimension like [Special Flag]. Then the MDX expressions could be:

For current year [Special Sales]:

([Special Flag].[SL_Flag].[True], [Measures].[Sales])

And for previous year [Special Sales]:

Sum(NonEmpty([Store].[Store].[Store].Members,

([Special Flag].[SL_Flag].[True], [Measures].[Sales])),

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

|||

That's probably a reasonable compromise and would be relatively easy to implement.

The only comment I would make is that modelling changing attributes in this matter should be the exception, not the rule. You would not want to take this to the extreme and end up with a cube that has lots of small dimensions as it increases the size of the aggregations and indexes which will reduce performance.

|||

Hi,

It's been a quite long time since you posted this.

Now, we have some changes regarding this special store's calculation.

Previously, we only select the current special store list, and for the last year value, we use current lists of special stores and if any store which was not special store in parallel period then we excluded it from the calculation.

I've tried this MDX into the cube and current year value works perfectly, but last year value doesn't work properly.

MDX for the last year :

Sum(NonEmpty([Store].[Store Hierarchy].currentmember,

([Special Flag].[SL_Flag].[True], [Measures].[Sales])),

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

> This mdx calculate all the last year value that store became a special in last year. it can't get the current special store lists.

But now, whether store was not a spcial store in last year, if store became a special store in selected date ( current) then we sum up all store's sale amount into the last year value.

below is the MDX for the last year:

([Special Flag].[SL_Flag].[True],

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

But when i browse the cube, it seems last year special flag is used for last year calculation. So, I can see all special store sales amount in last year. (not exclude store which is not a special store in current year)

I've tried to do different ways but still couldn't get any solutions yet.

It seems the MDX is something wrong.

If I want to use current special flag for the parallelperiod calculation how should I write MDX for that?

I think this logic makes sense to me but I don't know why it doesn't work.

I would appreciate if anybody can give me some comments.

Thanks.

MDX Question

All,

I have a simple MDX query to return results based on user i/p in search screen. User can type in trade code and the results should give all the source of it. The dimension TRade contains couple of million members that are not unique. (Only source + trade is unique)

The below works when there is a single member corresponsing to input (xxxx). If there are multiple members, it returns nothing.

I can't use filter function here as the trade dimension is large and it takes time to filter. I can't search using member key as the key is made of Trade code + source where source is not avaiable during search,

any solution?

SELECT Measures.[Value] on 0,

NON EMPTY ([Source].[Source].Members) on 1

from MyCube

WHere [Trade].[Trade Code].[xxxx]

Cheers,

Arun

dear Arun,

Create a view with all distinct values that you pretend to aggredate. And in the datasourceview of AS, import this view and use it as a dimension.

regards!!

|||

Hi Pedro,

I dont really want to do that. The dimension design is right. I have another hierarchy in the Trade dimension with levels as Source & Trade Code. this is exactly what I need.

But my problem is filtering using the member name when it appears more than once in the dimension.

Cheers,

Arun

|||

Arun,

Do you have something like this:

Source Trade 1 T11 1 T12 2 T21 3 T31 3 T32 3 T33

correct?!

|||

Arun,

As PedroCGD has mentioned, make a Distinct Trade Value for Filter Criteria, and donot think about Single trade as you example

SELECT Measures.[Value] on 0,

NON EMPTY ([Source].[Source].Members) on 1

from MyCube

WHere [Trade].[Trade Code].[xxxx]

But think about Ranges.

Make a selection criteria for Start Range and End Range. I hope you will understand.

Bhudev

|||

Saw the rply only now.

I had manageed to solve the problem myself. Below is the query.

Source System dimension: (this dimension will have <20 members)

Key - name

1 - ss1

2 - ss2

3 - ss3

4 - ss4

trade dimension : (this can have millions of members) - uniquekey : SourceID + tradecode

SourceID TradeCode Key 1 TC11 Trade.TradeCode.&[1]&[TC11] 1 TC12 Trade.TradeCode.&[1]&[TC12] 2 TC11 Trade.TradeCode.&[2]&[TC11] 2 TC22 Trade.TradeCode.&[2]&[TC22] 3 TC31 Trade.TradeCode.&[3]&[TC31]

Code Snippet

SELECT [Measures].[Value] ON 0,

NON EMPTY (

STRTOSET(" {" +

GENERATE ( [Source System].[Source].[Source]. Members,

"[Trade].[Trade Code].&[" + CSTR([Source System].[Source].CurrentMember.Member_Key ) + "]&[xxxxxxx]" ,

"," )

+ "}")

)

ON 1

FROM [MyCube]

MDX question

Hi,

Here is my question.

For the last year special store sales amount, we only calculate sales amount based on special store lists in current selected date.

If a store in current date is not a special store then we do not include this store for last year sales amount (even if this store was special store in last year). This means we don't care about last year store status and we only identify the special store status of all stores according to the date we selected.

In the fact, I join the flag ( which represents a special store) and added one colum for special sales calcualtion. (flag * net sales). In the cube, Currnet speical sales are correct but I couldn't get correct last year specail sales amount.

Below is the calculation for last year specail store sales amount but the numbers do not match.

IIF(([Measures].[flag], [Date].[Fiscal Hierarchy].CurrentMember)=False,0,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

Please give me some comments.

Thanks in advance.

Boolean values as measures just don't work well. There probably would be a way to write the MDX calculation, but the performance would be really bad probably to the point of being unusable.

You could implement the flag as it's own dimension, but probably the best approach is to implement the store dimension as a slowly changing dimension. What you would be after is a type 2 changing dimension. If you are not aware of what this is, you are basically adding a new record to the store dimension when the value of the flag changes

Below is a simplified example, notice that "Store 1" has StoreID = 1 and StoreID = 3. It is often common to store effective dates against the records for slowly changing dimensions to make it easier to figure out which dimension record applies to a given fact record.

StoreID StoreName SpecialFlag

1 Store 1 False

2 Store 2 False

3 Store 1 True

Then when you insert facts you insert the StoreID that was effective for the date of the respective facts.

StoreID DateID SalesAmount

1 20060101 100

3 20070601 100

Using this technique you would be able to create a "Special Store" attribute in your store dimension and filter using that.

|||

Thanks for the reply. I think I didn't give you a right explanation.

I understand what you suggested but could you take a look at this one more time?

Below is the details how it looks like :

Selected date : 20070101

Last year date : 20060101

Sales Fact

ID Store_key Date Sales

1 store 1 20070101 100.00

2 store 2 20070101 150.00

3 store 3 20070101 100.00

4 store 1 20060101 30.00

5 store 2 20060101 30.00

6 store 3 20060101 30.00

There is an anther fact table which has a flag.

Special_Store Fact

Special_Store_key Store_key Date Key SS_flag

1 store 1 20070101 True

2 store 1 20060101 False

3 store 2 20070101 False

4 store 2 20060101 True

5 store 3 20070101 False

6 store 3 20060101 True

Now I joined this 2 Fact to add Specail Store Sales into the Sales Fact

ID Store_key Date Sales SS_flag SS_Sales (SS flag * Sales)

1 store 1 20070101 100.00 True 100.00

2 store 2 20070101 150.00 False 0.00

3 store 3 20070101 100.00 True 100.00

4 store 1 20060101 30.00 False 0.00

5 store 2 20060101 30.00 True 30.00

6 store 3 20060101 30.00 True 30.00

From this data,

we calulate SS sales amount and the total is 130.00 which is not a problem to calculate in the cube.

My problem is that for the last year SS sales amount with time calculation we developed inside the cube,

time calculation sums up all SS_Sales, so last year total is 60.00.

But from the selected date , we do not consider last year store status. We only care current Special Store and From this list we calculate last year value. So, in this data, we need to get 30 (excluding store 2 since store 2 is not special store in the selected date 20070101).

As you mentioned, if boolean value does not work properly and affects performance then how can I approach in this situation? Any Suggestions?

Please let me know.

Thanks.

|||

I am pretty sure that my original suggestion of not adding this flag to the fact table and implementing a slowly changing dimension would work. But possibly a simpler solution might be to insert NULL insead of 0.00 into the SS_Sales measure and then do something like the following, which basically checks if there is a value for [Special Sales] in the current period.

IIF(IsEmpty({([Measures].[Special Sales], [Date].[Fiscal Hierarchy].CurrentMember)}),NULL,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

The only problem with this is that, if you have a hierarchy over the stores so that they roll up into groups of some sort then you will get incorrect results at the higher levels. If any store in the group was "sepcial" last year the value for the entire group would be included

Which would mean that you might have to do something like the following to force this expression to be evaluated over individual store members.

SUM( EXISTING [Store].[Store].[Store].Members ,

IIF(IsEmpty({([Measures].[Special Sales], [Date].[Fiscal Hierarchy].CurrentMember)}),NULL,

(parallelperiod([Date].[Fiscal Hierarchy].[fiscal year],1),[Measures].[Special Sales]))

)|||

There seems to be some inconsistency in the sample data: Store 3, 20070101 is shown as a special sale in the joined fact table, but not in Special_Store_Fact - I assume that is just a typo?

Anyway, since SS_Flag is already a field in the joined fact table, another approach would to create a simple true/false dimension like [Special Flag]. Then the MDX expressions could be:

For current year [Special Sales]:

([Special Flag].[SL_Flag].[True], [Measures].[Sales])

And for previous year [Special Sales]:

Sum(NonEmpty([Store].[Store].[Store].Members,

([Special Flag].[SL_Flag].[True], [Measures].[Sales])),

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

|||

That's probably a reasonable compromise and would be relatively easy to implement.

The only comment I would make is that modelling changing attributes in this matter should be the exception, not the rule. You would not want to take this to the extreme and end up with a cube that has lots of small dimensions as it increases the size of the aggregations and indexes which will reduce performance.

|||

Hi,

It's been a quite long time since you posted this.

Now, we have some changes regarding this special store's calculation.

Previously, we only select the current special store list, and for the last year value, we use current lists of special stores and if any store which was not special store in parallel period then we excluded it from the calculation.

I've tried this MDX into the cube and current year value works perfectly, but last year value doesn't work properly.

MDX for the last year :

Sum(NonEmpty([Store].[Store Hierarchy].currentmember,

([Special Flag].[SL_Flag].[True], [Measures].[Sales])),

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

> This mdx calculate all the last year value that store became a special in last year. it can't get the current special store lists.

But now, whether store was not a spcial store in last year, if store became a special store in selected date ( current) then we sum up all store's sale amount into the last year value.

below is the MDX for the last year:

([Special Flag].[SL_Flag].[True],

(ParallelPeriod([Date].[Fiscal Hierarchy].[Fiscal Year], 1),

[Measures].[Sales]))

But when i browse the cube, it seems last year special flag is used for last year calculation. So, I can see all special store sales amount in last year. (not exclude store which is not a special store in current year)

I've tried to do different ways but still couldn't get any solutions yet.

It seems the MDX is something wrong.

If I want to use current special flag for the parallelperiod calculation how should I write MDX for that?

I think this logic makes sense to me but I don't know why it doesn't work.

I would appreciate if anybody can give me some comments.

Thanks.

Saturday, February 25, 2012

MDX query based on a subquery

Hi,

I hope that some can help me with a small problem I have got. I am new to data warehousing and MDX and am wondering if it is possible to construct a query based on a subquery (something like a T-SQL IN Clause).

Want I want to do is take all the customers who has looked at one product category (ex Dairy products) and see what else they have looked at. I guess what I want to do is create some sort of a filter to be able to only take those users from the measure and slice them by the product dimension again.

I am using ProClarity and will also need to be able to use it in there.

I am thankful for any help or any pushes in the right direction :-).

Kind Regards

Stefan Ghose

Hi Stefan,

Here are 2 sample Adventure Works queries, which identify the customers who bought Clothing category products on Jan.1,2004, and their purchases in other product categories on the same day:

>>

-- Customers who bought Clothing on Jan.1,2004:

select

Non Empty [Product].[Product Categories].[Category] on 0,

NonEmpty([Customer].[Customer Geography].[Full Name]

* {[Date].[Calendar].[Date].&[915]},

{([Product].[Product Categories].[Category].&[3],

[Measures].[Internet Sales Amount])}) on 1

from [Adventure Works]

where [Measures].[Internet Sales Amount]

-- Purchases in each Category on Jan.1,2004, by Customers who bought Clothing:

select {[Measures].[Internet Sales Amount]} on 0,

Non Empty [Product].[Product Categories].[Category] on 1

from [Adventure Works]

where NonEmpty([Customer].[Customer Geography].[Full Name]

* {[Date].[Calendar].[Date].&[915]},

{([Product].[Product Categories].[Category].&[3],

[Measures].[Internet Sales Amount])})

>>

|||

Thank you soo much for your help Deepak! This was exactly what I was looking for! Now I can use this to try to make a dynamic Measuregroup that I can use in ProClarity...

-Stefan Ghose-

|||

I have found the exact answer that I was looking for. To be able to create a query that is based on a subquery you only need to select write the subquery in the FROM clause i.e

SELECT

NONEMPTY([User Dimension].[All].CHILDREN, [Measures].[Count]) ON ROWS,

[Measures].[Count] ON COLUMNS

FROM

( SELECT

NONEMPTY ([User Dimension].[All].CHILDREN) ON COLUMNS

FROM

[Cube]

WHERE

(

[Measures].[Count],

[Slicer Dimension].[Name].&[Value],

[Date Dimension].[Year - Month].[Year].&[2006].&[11]

)

)

WHERE

(

[Date Dimension].[Year - Month].[Year].&[2006].&[11],

[User Dimension.CHILDREN

)

An example of this can be found here:

http://sqljunkies.com/WebLog/hitachiconsulting/archive/2004/09/21/4295.aspx

MDX query based on a subquery

Hi,

I hope that some can help me with a small problem I have got. I am new to data warehousing and MDX and am wondering if it is possible to construct a query based on a subquery (something like a T-SQL IN Clause).

Want I want to do is take all the customers who has looked at one product category (ex Dairy products) and see what else they have looked at. I guess what I want to do is create some sort of a filter to be able to only take those users from the measure and slice them by the product dimension again.

I am using ProClarity and will also need to be able to use it in there.

I am thankful for any help or any pushes in the right direction :-).

Kind Regards

Stefan Ghose

Hi Stefan,

Here are 2 sample Adventure Works queries, which identify the customers who bought Clothing category products on Jan.1,2004, and their purchases in other product categories on the same day:

>>

-- Customers who bought Clothing on Jan.1,2004:

select

Non Empty [Product].[Product Categories].[Category] on 0,

NonEmpty([Customer].[Customer Geography].[Full Name]

* {[Date].[Calendar].[Date].&[915]},

{([Product].[Product Categories].[Category].&[3],

[Measures].[Internet Sales Amount])}) on 1

from [Adventure Works]

where [Measures].[Internet Sales Amount]

-- Purchases in each Category on Jan.1,2004, by Customers who bought Clothing:

select {[Measures].[Internet Sales Amount]} on 0,

Non Empty [Product].[Product Categories].[Category] on 1

from [Adventure Works]

where NonEmpty([Customer].[Customer Geography].[Full Name]

* {[Date].[Calendar].[Date].&[915]},

{([Product].[Product Categories].[Category].&[3],

[Measures].[Internet Sales Amount])})

>>

|||

Thank you soo much for your help Deepak! This was exactly what I was looking for! Now I can use this to try to make a dynamic Measuregroup that I can use in ProClarity...

-Stefan Ghose-

|||

I have found the exact answer that I was looking for. To be able to create a query that is based on a subquery you only need to select write the subquery in the FROM clause i.e

SELECT

NONEMPTY([User Dimension].[All].CHILDREN, [Measures].[Count]) ON ROWS,

[Measures].[Count] ON COLUMNS

FROM

( SELECT

NONEMPTY ([User Dimension].[All].CHILDREN) ON COLUMNS

FROM

[Cube]

WHERE

(

[Measures].[Count],

[Slicer Dimension].[Name].&[Value],

[Date Dimension].[Year - Month].[Year].&[2006].&[11]

)

)

WHERE

(

[Date Dimension].[Year - Month].[Year].&[2006].&[11],

[User Dimension.CHILDREN

)

An example of this can be found here:

http://sqljunkies.com/WebLog/hitachiconsulting/archive/2004/09/21/4295.aspx

MDX query based on a subquery

Hi,

I hope that some can help me with a small problem I have got. I am new to data warehousing and MDX and am wondering if it is possible to construct a query based on a subquery (something like a T-SQL IN Clause).

Want I want to do is take all the customers who has looked at one product category (ex Dairy products) and see what else they have looked at. I guess what I want to do is create some sort of a filter to be able to only take those users from the measure and slice them by the product dimension again.

I am using ProClarity and will also need to be able to use it in there.

I am thankful for any help or any pushes in the right direction :-).

Kind Regards

Stefan Ghose

Hi Stefan,

Here are 2 sample Adventure Works queries, which identify the customers who bought Clothing category products on Jan.1,2004, and their purchases in other product categories on the same day:

>>

-- Customers who bought Clothing on Jan.1,2004:

select

Non Empty [Product].[Product Categories].[Category] on 0,

NonEmpty([Customer].[Customer Geography].[Full Name]

* {[Date].[Calendar].[Date].&[915]},

{([Product].[Product Categories].[Category].&[3],

[Measures].[Internet Sales Amount])}) on 1

from [Adventure Works]

where [Measures].[Internet Sales Amount]

-- Purchases in each Category on Jan.1,2004, by Customers who bought Clothing:

select {[Measures].[Internet Sales Amount]} on 0,

Non Empty [Product].[Product Categories].[Category] on 1

from [Adventure Works]

where NonEmpty([Customer].[Customer Geography].[Full Name]

* {[Date].[Calendar].[Date].&[915]},

{([Product].[Product Categories].[Category].&[3],

[Measures].[Internet Sales Amount])})

>>

|||

Thank you soo much for your help Deepak! This was exactly what I was looking for! Now I can use this to try to make a dynamic Measuregroup that I can use in ProClarity...

-Stefan Ghose-

|||

I have found the exact answer that I was looking for. To be able to create a query that is based on a subquery you only need to select write the subquery in the FROM clause i.e

SELECT

NONEMPTY([User Dimension].[All].CHILDREN, [Measures].[Count]) ON ROWS,

[Measures].[Count] ON COLUMNS

FROM

( SELECT

NONEMPTY ([User Dimension].[All].CHILDREN) ON COLUMNS

FROM

[Cube]

WHERE

(

[Measures].[Count],

[Slicer Dimension].[Name].&[Value],

[Date Dimension].[Year - Month].[Year].&[2006].&[11]

)

)

WHERE

(

[Date Dimension].[Year - Month].[Year].&[2006].&[11],

[User Dimension.CHILDREN

)

An example of this can be found here:

http://sqljunkies.com/WebLog/hitachiconsulting/archive/2004/09/21/4295.aspx

Mdx query

Hello guys,

Assume I have a date dimention in a cube and I want to retrive data based on the StartDate and EndDate value. In short, I want to filter all records between StartDate value and EndDate value which is given by a user. Can any body give a general syntax or mdx query to achive this goal?

Sincerely,

Amde

Hello Amde

Assuming Analysis Services 2005:

SELECT {[Measures].[MyMeasures]} ON 0,

[MyDimension].[MyHierarchy].[MyLevel].members ON 1

FROM [MyCube]

WHERE {[Time].[Date].[<StartDate>] : [Time].[Date].[<EndDate>]}

|||

Thanks a lot michael,

But what if the the <StartDate> and <EndDate> values are parameter values that should be specified by a user? What will be the where condition in this case?

Sincerely,

Amde

|||The query itself needs to be the same. How would the user specify the parameters? Which client is the user using?|||

Hey michael,

That is a good question. I am going to write this query in the Report Designer; there will be report parameters <StartDate>and<EndDate> by which the user will specify and based on the parameter, I want to filter the record. I think this makes sense.

Sincerely,

Amde

|||

Ahhh... OK. Then I guess you just need to create two report parameters (for instance, named @.StartDate and @.EndDate). The values have to contain the unique member name for the dates. This could be something like [Time].[Date].&[20060518]. This value can the be passed to the MDX query. Now, I don't remember the exact syntax when you want to use report parameters in an MDX query, but I believe the WHERE statement should be something like this:

WHERE {StrToSet(@.StartDate.Value + ":" + @.EndDate.Value)}

|||

Hey Michael,

Thank you for sharing your idea, I know the syntax in reporting service; I will change the syntax and use it properly.

Sincerely,

Amde

MDX Parser

Hello,
Im currently running SEPT CTP, and im trying to create a report based on a
dataset filled by a MDX query. That query must have parameters.
I have defined the query in query designer, but after that I must edit the
query because some of my parameters include spaces ' ' and I must edit
StrToSet to surround my @.var with '[ ]' .
The problem is that i cant make any change to the query, it always gives the
error "An MDX expression was expected. An empty expression was found.". Even
when I switch from designer to hand-edit it gives the same error if I process
it.
I think it has somethin to do with the parser, because the StrTo... family
of functions expect a valid MDX expression as a parameter but all I have is
@.varname.
Help anyone? Thanks.hello Fernando,
How exactly are you changing your mdx query to accept the parameter values?
If you show me i may be able to help.
I've done it by running the query without any parameters to get the fields,
then editing the query to accept the parameters. This is done by placing an
'=' sign at the beginning of the query then at the end of each string of text
insert " & "
i.e
="with" & "member" &
and
"select" & "[sdjhfskljf].[" & Parameter!Value.aParameter &"] from columns, " &
etc etc
dont know if taht helps but i tried.
bobfoc
"Fernando Marçal" wrote:
> Hello,
> Im currently running SEPT CTP, and im trying to create a report based on a
> dataset filled by a MDX query. That query must have parameters.
> I have defined the query in query designer, but after that I must edit the
> query because some of my parameters include spaces ' ' and I must edit
> StrToSet to surround my @.var with '[ ]' .
> The problem is that i cant make any change to the query, it always gives the
> error "An MDX expression was expected. An empty expression was found.". Even
> when I switch from designer to hand-edit it gives the same error if I process
> it.
> I think it has somethin to do with the parser, because the StrTo... family
> of functions expect a valid MDX expression as a parameter but all I have is
> @.varname.
> Help anyone? Thanks.|||sorry made an error the parameter string should say [" &
Parameter!aParameter.Value &"] not [" & Parameter!Value.aParameter &"] got it
the wrong way round!
"bobfoc" wrote:
> hello Fernando,
> How exactly are you changing your mdx query to accept the parameter values?
> If you show me i may be able to help.
> I've done it by running the query without any parameters to get the fields,
> then editing the query to accept the parameters. This is done by placing an
> '=' sign at the beginning of the query then at the end of each string of text
> insert " & "
> i.e
> ="with" & "member" &
> and
> "select" & "[sdjhfskljf].[" & Parameter!Value.aParameter &"] from columns, " &
> etc etc
> dont know if taht helps but i tried.
> bobfoc
> "Fernando Marçal" wrote:
> > Hello,
> >
> > Im currently running SEPT CTP, and im trying to create a report based on a
> > dataset filled by a MDX query. That query must have parameters.
> > I have defined the query in query designer, but after that I must edit the
> > query because some of my parameters include spaces ' ' and I must edit
> > StrToSet to surround my @.var with '[ ]' .
> > The problem is that i cant make any change to the query, it always gives the
> > error "An MDX expression was expected. An empty expression was found.". Even
> > when I switch from designer to hand-edit it gives the same error if I process
> > it.
> >
> > I think it has somethin to do with the parser, because the StrTo... family
> > of functions expect a valid MDX expression as a parameter but all I have is
> > @.varname.
> >
> > Help anyone? Thanks.|||Hi bobfoc,
I've manage to use the parameters by starting the query with query designer.
What is absurd is this: I start the query with query designer, and when I
switch to query mode the query is auto-generated and the error is still
produced.
"bobfoc" wrote:
> sorry made an error the parameter string should say [" &
> Parameter!aParameter.Value &"] not [" & Parameter!Value.aParameter &"] got it
> the wrong way round!
> "bobfoc" wrote:
> > hello Fernando,
> >
> > How exactly are you changing your mdx query to accept the parameter values?
> > If you show me i may be able to help.
> >
> > I've done it by running the query without any parameters to get the fields,
> > then editing the query to accept the parameters. This is done by placing an
> > '=' sign at the beginning of the query then at the end of each string of text
> > insert " & "
> > i.e
> > ="with" & "member" &
> > and
> > "select" & "[sdjhfskljf].[" & Parameter!Value.aParameter &"] from columns, " &
> >
> > etc etc
> >
> > dont know if taht helps but i tried.
> >
> > bobfoc
> >
> > "Fernando Marçal" wrote:
> >
> > > Hello,
> > >
> > > Im currently running SEPT CTP, and im trying to create a report based on a
> > > dataset filled by a MDX query. That query must have parameters.
> > > I have defined the query in query designer, but after that I must edit the
> > > query because some of my parameters include spaces ' ' and I must edit
> > > StrToSet to surround my @.var with '[ ]' .
> > > The problem is that i cant make any change to the query, it always gives the
> > > error "An MDX expression was expected. An empty expression was found.". Even
> > > when I switch from designer to hand-edit it gives the same error if I process
> > > it.
> > >
> > > I think it has somethin to do with the parser, because the StrTo... family
> > > of functions expect a valid MDX expression as a parameter but all I have is
> > > @.varname.
> > >
> > > Help anyone? Thanks.|||that's just wierd, I've had some strange problems with reporting services
before but nothing that a reboot hasn't fixed.
I've never used query designer, i prefer writing from scratch then you
understand it better, but then i also work on the philosophy of if it works,
leave it unless you have to change it.
Glad you kid of sorted it,
bob
"Fernando Marçal" wrote:
> Hi bobfoc,
> I've manage to use the parameters by starting the query with query designer.
> What is absurd is this: I start the query with query designer, and when I
> switch to query mode the query is auto-generated and the error is still
> produced.
> "bobfoc" wrote:
> > sorry made an error the parameter string should say [" &
> > Parameter!aParameter.Value &"] not [" & Parameter!Value.aParameter &"] got it
> > the wrong way round!
> >
> > "bobfoc" wrote:
> >
> > > hello Fernando,
> > >
> > > How exactly are you changing your mdx query to accept the parameter values?
> > > If you show me i may be able to help.
> > >
> > > I've done it by running the query without any parameters to get the fields,
> > > then editing the query to accept the parameters. This is done by placing an
> > > '=' sign at the beginning of the query then at the end of each string of text
> > > insert " & "
> > > i.e
> > > ="with" & "member" &
> > > and
> > > "select" & "[sdjhfskljf].[" & Parameter!Value.aParameter &"] from columns, " &
> > >
> > > etc etc
> > >
> > > dont know if taht helps but i tried.
> > >
> > > bobfoc
> > >
> > > "Fernando Marçal" wrote:
> > >
> > > > Hello,
> > > >
> > > > Im currently running SEPT CTP, and im trying to create a report based on a
> > > > dataset filled by a MDX query. That query must have parameters.
> > > > I have defined the query in query designer, but after that I must edit the
> > > > query because some of my parameters include spaces ' ' and I must edit
> > > > StrToSet to surround my @.var with '[ ]' .
> > > > The problem is that i cant make any change to the query, it always gives the
> > > > error "An MDX expression was expected. An empty expression was found.". Even
> > > > when I switch from designer to hand-edit it gives the same error if I process
> > > > it.
> > > >
> > > > I think it has somethin to do with the parser, because the StrTo... family
> > > > of functions expect a valid MDX expression as a parameter but all I have is
> > > > @.varname.
> > > >
> > > > Help anyone? Thanks.

Monday, February 20, 2012

MDX in MS Reporting Services

Hi

(All using 2005 release)

I've written a MSRS report based on an OLAP data source which is working fine in the report designer but once I have deployed it to the report server & attempt to browse it I get the following errror:

An error has occurred during report processing.

Query execution failed for data set 'DataSet1'.
Line 1: Incorrect syntax near '{'. Line 1: Incorrect syntax near 'Tbl Acc Codes'

It seems to be pointing to an mdx error although I've constructed the query just by using the drag & drop tool.

Are there any known problems with MSRS & MDX & if not can any of you MDX gurus spot anything wrong with the qry:

SELECT NON EMPTY { [Measures].[Ratio Val] } ON COLUMNS, NON EMPTY { ([Tbl Ac Year].[AcYear].[AcYear].ALLMEMBERS * [Tbl Comparison Group].[Tbl Comparison Group].[Tbl Comparison Group].ALLMEMBERS * [Tbl Comparison Group].[Description].[Description].ALLMEMBERS * [Tbl Group].[Tbl Group].[Tbl Group].ALLMEMBERS * [Tbl Group].[Display Order].[Display Order].ALLMEMBERS * [Tbl Clients].[Tbl Clients].[Tbl Clients].ALLMEMBERS * [Tbl Acc Codes].[Acc Desc Hierarchy].[Description].ALLMEMBERS * [Tbl Acc Codes].[Acc Code Hierarchy].[Tbl Acc Codes].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [FE Benchmark] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

Thanks :)

Wayne

  • Try and paste your query into MDX editor in SQL Managment Studio. It will allow you to perform a syntax check on your query.

    Edward.
    --
    This posting is provided "AS IS" with no warranties, and confers no rights.

  • MDX Hierarchy help

    I have two calendar hierarchies in a 2005 SSAS cube. I have to make some calculations based on the date level, but of course, my calculated measures dont work when the wrong hierarchy is chosen.

    I have tried to look at the .hierarchy and hierarchy() function but am unable to really understand how they work and I haven't been terribly successful looking online for info on them.

    Has anyone had a similar issue? How did you test for the current hierarchy?

    Here's an Adventure Works example, when either the Calendar or Fiscal hierarchy is selected on rows:

    >>

    With Member [Measures].[DateHierarchy] as

    Axis(1).Item(0).Item(0).Hierarchy.Name

    select {[Measures].[Order Quantity],

    [Measures].[DateHierarchy]} on 0,

    Non Empty [Date].[Calendar].[Calendar Year] on 1

    from [Adventure Works]

    -

    Order Quantity DateHierarchy
    CY 2001 11,848 Calendar
    CY 2002 60,918 Calendar
    CY 2003 124,615 Calendar
    CY 2004 77,395 Calendar

    >>

    Another approach is to test whether the current member of each hierarchy is the default member (assuming that only 1 hierarchy has been navigated).