x
Solved

# MDX Count

Posted on 2011-03-15
Medium Priority
1,030 Views
Consider this result is given by MDX

select  {[Measures].[InventoryValue] }
on 0
from [TD Analysis]

The Result is like

2009, Jan, 1-10, ITemA, Day1, 5000
2009, Jan, 1-10, ItemA, Day2, 200
2009,  Jan , 1-10, ItemB, Day2., 300
2009, Jan , 1-10, ItemC, Day2, 200
2009, jan, 11-20, itemE, Day3, 200

I want the final result

2009, Jan, 1-10, Count(Items), Sum(inventoryValue)

the results

2009, Jan, 1-10, 1, Day1, 5000
2009, Jan, 1-10, 3, Day2, 700
2009, Jan, 11-20, 1, Day3, 200

Thanks.
0
Question by:obtek
• 4
• 2

LVL 10

Expert Comment

ID: 35135701
Hi

There are several ways of doing that.

You can add measure to your cube (count) - this is recommended and then add to query and remove range name. If you cannot remove range name then you add calculated member with your count measure.

if you don't have the measure then you can create calculated member with count function.

Hope that points you in the right direction.
Emil
0

Author Comment

ID: 35135722
I need the syntax, as I am having trouble with it.

Consider Item Range, Item are in one dimension and Date is a different dimension.  Would like to have MTD Avg, Median, I just went with simplest (which is the count)

Thx
0

LVL 10

Expert Comment

ID: 35136246
Hi

Remove this dimension attribute [Range Name].Members

Here is the MDX Count syntax
http://msdn.microsoft.com/en-us/library/ms144823.aspx

Regards
Emil
0

Author Comment

ID: 35136359
Please give me full syntax.  I refered to all of these documentation and could not come up with the statement. I am getting the same number for all days of the month. If I could have deciphered the documentation, I would not have posted the question.

Thx
0

Accepted Solution

obtek earned 0 total points
ID: 35146579
Added the count as a measure using DISTINCT COUNT aggregation. as part of design.
0

Author Closing Comment

ID: 35178731
I was looking for a more generic calculation I can extend. Instead went with design approach.
0

## Featured Post

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.