Good afterenoon forum
I am running into an issue that I have not been able to work out on my own. Hopefully someone out here has run into a similar issue and can pass along their lessons learned.
I am working on a query to return the top 10 items purchased by our top 25 customers. Both the Customer and Product dimensions have multiple hierarchies and multiple levels in each hierarchy.
The Customers dimension hierarchy level consists of a parent customer, bill to customer, and ship to customer. The Product dimension hierarchy levels consist of Group, Division, Brand, and Product (SKU).
I want the query to return the top 25 parent customers and the top 10 items they have purchased at the Product\SKU level of the product dimension.
The query that I am using is below and runs with no errors, but I am getting null values in the Sales Dollars measure which is not correct.
Select [sales dollars]onrows
Generate(nonempty(TopCount(Descendants([Customers].[Customers].[All Customers],[Parent Customer]),25,[sales dollars])) ,
Crossjoin([Customers].[Customers].Currentmember,TopCount(Descendants([Products].[Products].[All Products],[Product]), 10, [sales dollars])))ONROWS
from [Sales]
After much head scratching and running other queries and existing queries I think part of my problem is the fact that we have multiple members with the same name at the Parent level
of the customer dimension because of a concatenated key.
The keys are different but the names are the same. Example: [Customers].[Customers].[All Customers].[Customer 1] could refer to [Customers].[Customers].[Parent Customer].[1].[1] or [Customers].[Customers].[Parent Customer].[1].[2].
When I change the query above to the query below I get the correct answer to my question for the one customer I am testing.
Select [sales dollars]onrows
Generate( [Customers].[Customers].[Parent Customer].[1].[1] ,
Crossjoin([Customers].[Customers].Currentmember,TopCount(Descendants([Products].[Products].[All Products],[Product]), 10, [sales dollars])))ONROWS
from [Sales]
However the query below returns null dollars just as the main query.
Select [sales dollars]onrows
Generate( [Customers].[Customers].[All Customers].[Customer 1 ,
Crossjoin([Customers].[Customers].Currentmember,TopCount(Descendants([Products].[Products].[All Products],[Product]), 10, [sales dollars])))ONROWS
from [Sales]
So my issues to me with the [Customers].[Customers].Currentmember value being passed into the Crossjoin function during the generate function of the top items list. When I pass in a hierarchy level member the query returns correctly but when I return just the hierarchy member the results are incorrect.
Has anyone seen this before or do you have a way to force the top 25 customers to be in the hierarchy level format.
Thank you in advance for any input or assistance you may have.