Nested TOPCOUNT between 2 attributes within same dimension using GENERATE function not giving desired results

V Anusha 0 Reputation points
2023-11-06T12:10:10.5+00:00

Hi,

I am trying to achieve top 5 subcategories for each of the category in top 5 categories. I have used GENERATE and TOPCOUNT as shown in the below code for achieving the result. But it isn’t working as expected. Instead of returning top 5 sub-categories for each category it is returning 5 records in totaltopcount issue

Below is screenshot from Adventure Works cube, where we can see each category has more than 5 sub-categories.AD cube browse1

Below is the attribute relationship on the product dimension. Category and subcategory are directly related as shown below.attribute relationship

When I use subcategory and model name, we get proper results. These two attributes are not directly related.

Selecting top10 model names in each sub-category.top10

Selecting top5 model names in each sub-category.top5

Below is the screenshot from Adventure Works cube for sub-category and model name

AD cube browse2

Is this expected behavior? Or am I missing anything? Or is this a bug? Can anyone please provide inputs on the scenario. I have used Adventure Works cube to demonstrate the actual scenario we are working on.

Regards,

Anusha

SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,290 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Alexei Stoyanovsky 3,416 Reputation points
    2023-11-07T10:00:06.1733333+00:00

    You misplaced a crossjoin when copying the example from the Generate documentation page

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.