dbTalk Databases Forums  

Display Top Ns and sum of All others

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss Display Top Ns and sum of All others in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Priya1
 
Posts: n/a

Default Display Top Ns and sum of All others - 06-02-2006 , 09:26 AM






We need to display a Geography Dimension with levels

NATIONAL
REGIONS
AREAS

As

National
Region1
Area1
Area2
All Other Areas Under Region1
Region2
Area3
Area4
All Other Areas Under Region2
All Other Regions Under National

All Other Areas Under Region1 – Sum of the areas under Region1 that are not
displayed in the report under region1. Similarly Region2

All Other Regions Under National – Sum of the Regions under National that are
not displayed in the report under National.

The members that are selected to be displayed in the report can be a variable
list.
Similarly the conditions to display the child for each levels also is
variable

(For eg)
Top 2 Regions, Bottom 3 Areas for one report
And
Regions whose value > 100, Top 3 Areas for one report

We have formed the query to display the report but for the “ALL Other..”
members

SELECT { [Measures].[values] } on axis(0),
ORDER(
Hierarchize(
{
GENERATE(
GENERATE(
Head(Order([GEOGRAPHY].[GEO].[NATIONAL].members, [Measures]. [VALUES], DESC),
1),
{
[GEOGRAPHY].[geo].CurrentMember,
Head(Order(Descendants ([GEOGRAPHY]. [geo].CurrentMember,[GEOGRAPHY].[GEO].
[REGIONS]), [Measures]. [VALUES], DESC), 2)
}
),

[GEOGRAPHY].[geo].CurrentMember,
Head(Order(Descendants ([GEOGRAPHY]. [geo].CurrentMember,[GEOGRAPHY].[GEO].
[AREAS]), [Measures]. [VALUES], DESC), 2)
}
)
}
),
[Measures].[VALUES], DESC)
on axis(1)
FROM [USERDEMO 1 4 U ABC C99980_4325__20030317]

Can you help us in completing this query or suggesting a better optimized way
of retrieving the report?

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.