![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
hi does anyone see anything that can be improved with the following MDX? thanks ahead. --This returns TOP 1000 --Brokers with their ZipCodes and Actual Sales, Actual Tickets, and Actual Activities --For a given Territory --and date range --and Sales Range --and Activity Range with member [Measures].[zip] as '[Firm].[standard].currentmember.properties("Zip")' Member [Measures].[SalesAmt] as 'CoalesceEmpty([Measures].[Sales Amt],0)' Member [Measures].[TicketCnt] as 'CoalesceEmpty([Measures].[Ticket Qty],0)' Member [Measures].[ActivityCnt] as 'CoalesceEmpty([Measures].[Activity Cnt],0)' SET [Times] as '{ [Time].[Standard].[Month].&[1/1/2004] : [Time].[Standard].[Month].&[12/1/2004] }' MEMBER [Measures].[Actual_Sales] AS 'SUM({[Measures].[zip]},SUM({[Times]},([Measures].[SalesAmt])))' MEMBER [Measures].[Actual_Ticket] AS 'SUM({[Measures].[zip]},SUM({[Times]},([Measures].[TicketCnt])))' MEMBER [Measures].[Actual_Activity] AS 'SUM({[Measures].[zip]},SUM({[Times]},([Measures].[ActivityCnt])))' SET [FilterSales] AS 'FILTER( NONEMPTYCROSSJOIN ( {DESCENDANTS([Firm].[Standard].[All Firms],[Firm].[Standard].[Contact])}, {[Territory Current].[Standard].[Territory].[Ben Alcid] }, {[Times]}, {[Company].[Standard].[Organization].[CompanyName]}, {[Transaction Type].[Standard].[Type].[Paid]}, 1 ), ([Measures].[Actual_Sales]) >= 1 and ( [Measures].[Actual_Sales]) <= 5000000 and ([Measures].[Actual_Activity]) >= 1 and ([Measures].[Actual_Activity]) <= 100 )' |
#3
| ||||
| ||||
|
| --This returns TOP 1000 |
| Newsgroups: microsoft.public.sqlserver.olap |
#4
| |||
| |||
|
|
Firstly, what is meant by "TOP 1000" - it looks like Subset() is selecting the first 1000 from [FilterSales]. Secondly, some simplification seems possible - why are the CoalesceEmpty() calculated measures needed? --This returns TOP 1000 --Brokers with their ZipCodes and Actual Sales, Actual Tickets, and Actual Activities --For a given Territory --and date range --and Sales Range --and Activity Range with member [Measures].[zip] as '[Firm].[standard].currentmemb-er.properties("Zip")' SET [Times] as '{ [Time].[Standard].[Month].&[1/-1/2004] : [Time].[Standard].[Month].&[12-/1/2004] }' MEMBER [Measures].[Actual_Sales] AS 'SUM({[-Times]},([Measures].[Sales Amt]-))' MEMBER [Measures].[Actual_Ticket] AS 'SUM({[-Times]},([Measures].[Ticket Cnt-]))' MEMBER [Measures].[Actual_Activity] AS 'SUM({[-Times]},([Measures].[Activity C-nt]))' SET [FilterSales] AS 'FILTER( NONEMPTYCROSSJOIN ( {DESCENDANTS([Firm].[Standard]-.[All Firms],[Firm].[Standard].[Cont-act])}, {[Territory Current].[Standard].[Territory-].[Ben Alcid] }, {[Times]}, {[Company].[Standard].[Organiz-ation].[CompanyName]}, {[Transaction Type].[Standard].[Type].[Paid]-}, 1 ), ([Measures].[Actual_Sales]) >= 1 and ( [Measures].[Actual_Sales]) <= 5000000 and ([Measures].[Actual_Activity]) >= 1 and ([Measures].[Actual_Activity]) <= 100 )' Select {[Measures].[zip], [Measures].[Actual_Sales], [Measures].[Actual_Ticket],[Me-asures].[Actual_Activity]} on columns, { ORDER( SUBSET ({[FilterSales]} ,0,1000 ), [Measures].[zip], BASC ) } --DIMENSION PROPERTIES [Firm].[standard].properties("-Zip") on rows From SalesActivity Also, if the [Times] set is large, an equivalent set using higher aggregations can improve performance: http://groups-beta.google.com/group/...rver.olap/msg/ dacc5ced4823970a Newsgroups: microsoft.public.sqlserver.olap From: "Chris Webb" <OnlyForPostingToNewsgro... (AT) hotmail (DOT) c-om Date: Fri, 31 Dec 2004 04:01:01 -0800 Subject: RE: Problem with MDX query I don't think the query is hanging, I think it's just taking a very long time to complete! Summing up all those days in your date range is going to take a long time, plus I'll bet that your second query (because it doesn't mention the YearMonthDay dimension at all) probably hits aggregations whereas your first query doesn't. Since this is a fairly common problem I've just made it the subject of the first entry of my new blog, which you can read here: http://spaces.msn.com/members/-cwebbbi/Blog/cns!1pi7ETChsJ1un-_2s41jm9I. .. In your case, I think the approach of replacing the day members in your day range set with common ancestors could solve the problem. HTH, Chris - Deepak Deepak Puri Microsoft MVP - SQL Server *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#5
| |||
| |||
|
| The link that I provided in my post lets the user specify an arbitrary |
| But you don't need to do this for Sum() function, since it will |
| Since "Zip" is already a Member Property, you could create a Virtual |
#6
| |||
| |||
|
|
Here are inline responses to your clarifications: 1) ---------------------------------------------------------- If I change to Year Level instead of a lower level Month it is faster. But unfortunately I can not do this because originally the requirement from the business is that the user can choose any day range so it was worst before when it was at the Day Level....since then I have moved up to the Month Level....I can not go up to the Year Level because the users want to see results across multiple months. The link that I provided in my post lets the user specify an arbitrary time range at a lower level, then converts it into an optimized combination of higher and lower members. So this should work in your scenario, even at [Day] level. ---------------------------------------------------------- 2) ---------------------------------------------------------- The CoalesceEmpty functions you see are there because since this is a virtual cube I am referencing (SalesActivity) the numbers can be Empty so I am just replacing it with zero where appropriate (because zero means something here, example: we have sales but no activities for the criteria selected or vice versa). But you don't need to do this for Sum() function, since it will effectively treat empty as 0 - this could be faster. ---------------------------------------------------------- 3) ---------------------------------------------------------- Should I Create a new Location dimension (State,County,City,ZipCode,Latitude,Longitude) with ZipCode as the Lowest Level and Latitude and Longitude as Dimension Properties and put the column ZipCode inside the Fact Tables so that it can be referenced quickly? Since "Zip" is already a Member Property, you could create a Virtual Dimension, and compare its performance to adding a new dimension from a ZipCode field in the fact table. But can multiple contacts have the same ZipCode - in which case, do you still need to return the contacts along with the zip codes? If this is so, then something like: NonEmptyCrossJoin([ZipCode].[Zip].Members, DESCENDANTS([Firm].[Standard].[All Firms],[Firm].[Standard].[Contact]), {[Territory Current].[Standard].[Territory].[Ben Alcid]}, {[Times]}, {[Company].[Standard].[Organization].[CompanyName]}, {[Transaction Type].[Standard].[Type].[Paid]}, 2) could be returned on rows, already ordered by Zip. ---------------------------------------------------------- - Deepak Deepak Puri Microsoft MVP - SQL Server *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
#7
| |||
| |||
|
| Newsgroups: microsoft.public.sqlserver.olap |
![]() |
| Thread Tools | |
| Display Modes | |
| |