April 15, 2008 at 4:23 am
Hi,
I need a simple (if possible) MDX query on a cube.
My starscheme looks like this (simplified for this question ) :
- a Fact table 'Sales' with a measure 'Quantity'
- a Dimension table 'Product
The MDX query I need should list the top 10 products sold ( in terms of quantity ), completed with the aggregated
result for the rest of the products.
Example :
Product 1 5.320
Product 2 4.924
...
Product 10 1.923
Rest 2.345
So far, I have only used very simple MDX selects.
Thanks in advance,
Franky
Franky L.
April 16, 2008 at 6:52 am
Hi Steve,
Thanks for the inputs.
A nice article indeed on the topcount() function.
This helps me to solve the first part of my question.
Any tips on the 2nd part.
How do I add to my top 10 results the aggregated result of the rest of the dimension members ?
Regards,
Franky
Franky L.
April 16, 2008 at 8:22 am
You could possibly utilize the Except function [EXCEPT( )]. You'd probably want to create a named set for the top 10 initially, then use that as the excluded set of items (using the except function) to create a calc member. So in rough pseudo code....
With
Set setTop10 AS
Member allElse AS SUM(EXCEPT( )
SELECT
{setTop10, allElse} on 1,
{[Measures].[Qty_sold]} on 0
FROM
[some_cube]
Steve.
April 16, 2008 at 8:30 am
Hi Steve,
In the meantime I found another syntactical solution on the web.
Here's an example.
WITH
SET [TCat] AS
TopCount([Product].[Subcategory].[Subcategory],10,[Measures].[Sales Amount])
MEMBER [Product].[Subcategory].[Other] AS
Aggregate([Product].[Subcategory].[Subcategory] - TCat)
SELECT { [Measures].[Sales Amount] } ON COLUMNS,
TCat + [Other] ON ROWS
FROM [Adventure Works]
;
Franky L.
May 17, 2011 at 5:28 am
Hi Franky,
thank you soooo much for posting your solution. I need exactly the same like you.
You saved my day! :w00t:
Greetings...
February 6, 2012 at 2:33 pm
Thank you for this post.
I'm trying to add the percentage. This is what I have:
WITH
SET [TCat] AS TopCount([Product].[Subcategory].[Subcategory],10,[Measures].[Sales Amount])
MEMBER [Product].[Subcategory].[Other] AS Aggregate([Product].[Subcategory].[Subcategory] - TCat)
MEMBER [Measures].[Percent] AS [Measures].[Sales Amount] / ([Measures].[Sales Amount],[Product].[Subcategory].CurrentMember.Parent),format_string='0.00%'
SELECT{ [Measures].[Sales Amount], [Measures].[Percent] } ON COLUMNS,
TCat + [Other] ON ROWS
FROM[Adventure Works]
It works fine, except for the [other].
Can somebody help here?
Thanks a lot,
lab
February 14, 2013 at 12:39 am
Hi,
The above query work for single dimension but not for two dimensions . i can able to order top 30 count but i am unable to add rest total ......mdx Query to get top 30 count
select {[Measures].[Sum]} on columns,
Generate({[V Airline].[Airline Ds].members},{TopCount(Order(HIERARCHIZE(crossjoin([V Airline].[Airline Ds].currentmember ,[v RPTS TRNS Visits].[DMA Ds].members)),[Measures].[Sum],BDESC),30,[Measures].[Sum])}) on rows from [Cube_ATA] where ([v RPTS TRNS Visits].[Country Cd].&[USA])
its retrieving top 30 records . Here we using two dimension Airline and DMA . So i couldn't able to get the Total of the rest. Please help
Thanks in Advance ...
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply