Solved

MDX Count

Posted on 2011-03-15
6
1,022 Views
Last Modified: 2016-02-15
Consider this result is given by MDX

select  {[Measures].[InventoryValue] }
 on 0
      , ([TradeDate].[Trade Year].[Trade Year], [TradeDate].[Trade Month].[Trade Month],  ItemPriceRange.[Range Name].Members,
            [TradeDate].[TDHierachy].[Trade Day].Members)) on 1
       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
Comment
Question by:obtek
  • 4
  • 2
6 Comments
 
LVL 10

Expert Comment

by:itcouple
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

by:obtek
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

by:itcouple
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:obtek
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

by:
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

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

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Connecting to multiple databases to create a Dashboard 5 48
Database Design Dilemma 6 58
Check ALL SP in database make sure there are no errors 17 43
query optimization 6 15
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question