SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


MDX Query filtering on two different dimensions using 'OR' operator


MDX Query filtering on two different dimensions using 'OR' operator

Author
Message
Simon E Doubt
Simon E Doubt
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 895
I need help with a simple MDX query.

Suppose I have a measure group linked to a fact table called Flights, which records air traffic information.
There are some attributes in that fact table:

FactFlights
DestinationCity
ArrivalCity
FlightTime (how many minutes to get from Destination to Arrival)
...

Then I have two cube dimensions, one linked to DestinationCity, and one linked to ArrivalCity.

DimDestinationCity
DimArrivalCity


Those dimensions have a couple of attributes, including City, with memebers like 'Seattle', 'New York', 'Los Angeles', etc.

I need to write an MDX query that returns data from the FactFlights measure gropu where a city appears in EITHER the DestinationCity OR the ArrivalCity.

In TSQL this would be trivial.
Something like:

SELECT
DestinationCity,
ArrivalCity,
FlightTime
FROM Flights
WHERE
DestinationCity = 'Seattle'
OR
ArrivalCity = 'Seattle'

Any help/guidance would be greatly appreciated.

Thanks!
sneumersky
sneumersky
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4088 Visits: 487
Do you need to display one sum of flight time for the whole set of 2 members collectively; or, do you need to group the data in a different way?
sneumersky
sneumersky
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4088 Visits: 487
Off topic a bit:

Also, from a design perspective, I would have only one PHYSICAL dimension for the airport and use role playing dimensions.....one for the departure city and one for the arrival city. I cannot tell if that's what you did here on not.
Simon E Doubt
Simon E Doubt
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 895
sneumersky (1/31/2014)
Do you need to display one sum of flight time for the whole set of 2 members collectively; or, do you need to group the data in a different way?


Thanks very much for the reply.
It's a detail/line report, so I'm not too concerned about the grouping for now.
Simon E Doubt
Simon E Doubt
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 895
sneumersky (1/31/2014)
Off topic a bit:

Also, from a design perspective, I would have only one PHYSICAL dimension for the airport and use role playing dimensions.....one for the departure city and one for the arrival city. I cannot tell if that's what you did here on not.


As far as I can tell, there is only one physical dimension (DimCity).
How can I tell if these are 'role playing' dimensions?
sneumersky
sneumersky
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4088 Visits: 487
If you just wanted one cell to display as an answer, I would put the destination city member of Seattle and the departure city member of Seattle in the WHERE clause and just ask for the FlightTime aggregate on columns.

It all depends on what you want as row and column headers.
Simon E Doubt
Simon E Doubt
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 895
sneumersky (1/31/2014)
If you just wanted one cell to display as an answer, I would put the destination city member of Seattle and the departure city member of Seattle in the WHERE clause and just ask for the FlightTime aggregate on columns.

It all depends on what you want as row and column headers.


Good point.
Assume I want the following, as column headers:

Date
Departure City
Arrival City
Time In Flight

As I mentioned, it's sort of a line/detail report - there's not much analysis going on.

Thanks for the continued help.
Simon E Doubt
Simon E Doubt
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 895
sneumersky (1/31/2014)
If you just wanted one cell to display as an answer, I would put the destination city member of Seattle and the departure city member of Seattle in the WHERE clause and just ask for the FlightTime aggregate on columns.

It all depends on what you want as row and column headers.


Good point.
Assume I want the following, as column headers:

Date
Departure City
Arrival City
Time In Flight

As I mentioned, it's sort of a line/detail report - there's not much analysis going on.

Thanks for the continued help.
sneumersky
sneumersky
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4088 Visits: 487
Defeating the purpose of SSAS IMO.....but try this:

In pseudocode...

NonEmpty( (Day Level of Date Dimension) * (Seattle Member of Departure City) * (Seattle Member Of Arrival City)
)
ON ROWS

FlightTime
ON COLUMNS

FROM [YOUR CUBE]
Simon E Doubt
Simon E Doubt
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1655 Visits: 895
sneumersky (1/31/2014)
Defeating the purpose of SSAS IMO.....but try this:

In pseudocode...

NonEmpty( (Day Level of Date Dimension) * (Seattle Member of Departure City) * (Seattle Member Of Arrival City)
)
ON ROWS

FlightTime
ON COLUMNS

FROM [YOUR CUBE]




Thanks very much. I will give this a try.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search