Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How can I get a subset of hierarchy members

Posted on 2011-05-09
3
Medium Priority
?
1,524 Views
Last Modified: 2016-02-15
How can I get a known subset of hierarchy members when slicing a cube.  The code attached (against Adventure Works) will work.  It will return all reseller sales in Arlington, Texas between 7/1/2005 and 7/1/2006.  ALMOST what I want.  If I change &[Arlington]&[TX] to allmembers - a get a result set for all Cities in the hierarchy.

But I want just Arlington and Atlanta.  If I uncomment Atlanta, I get "The City hierarchy is used more than once in the Crossjoin function."  How can I limit my result set to just two cities??

(I'm offering 500 points here.  Please give me working code.  Thankyou.)
select 
{
    [Measures].[Reseller Order Count]
}
on columns,
non empty
(
    [Geography].[City].[City]
) 
on rows
from 
(
    select 
    (
        { 
                [Date].[Date].&[20050701]  
            :   [Date].[Date].&[20060701]  
            * [Geography].[City].&[Arlington]&[TX]      
//            * [Geography].[City].&[Atlanta]&[GA]  
        } 
    ) on 0
    from [Adventure Works]
)

Open in new window

0
Comment
Question by:jflanner
  • 2
3 Comments
 

Accepted Solution

by:
jflanner earned 0 total points
ID: 35727589
I figured this out.  You simply have to define the hierarchy members you want as a set.  

I am using Calgary instead of Atlanta in the example attached because they are not adjacent members of the hierarchy.  Back to my original question - Arlington : Atlanta would have produced the desired results - but only because the members are adjacent.
select 
{
    [Measures].[Reseller Order Count]
}
on columns,
non empty
(
    [Geography].[City].[City]
) 
on rows
from 
(
    select 
    (
        { 
                [Date].[Date].&[20050701]  
            :   [Date].[Date].&[20060701]  
            *   {
                    [Geography].[City].&[Arlington]&[TX],         
                    [Geography].[City].&[Calgary]&[AB]
                }
        } 
    ) on 0
    from [Adventure Works]
)

Open in new window

0
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 35745287
yea you got it.
0
 

Author Closing Comment

by:jflanner
ID: 36439977
I figured this out on my own.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Suggested Courses

577 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