March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
I am trying write a DAX or Power Query to show the top 5 Categories of tickets in each individual months for a Bar Chart and a Pivot Table. There are several filters set already on this page and visual.
Solved! Go to Solution.
Hi @Viperchick007,
There are several methods to get the top 5 categories, Mest way is to get using the DAX, but since this is added under the Power Query will give you that method,
Using Power Query
Sort Data by Ticket Count:
Add a Rank Column:
Filter for Top 5:
Load Data into Power BI:
To show the Top 5 Categories of tickets by individual months in Power BI for a Bar Chart and a Pivot Table, follow these steps:
Create a Measure for Ticket Count: Calculate the total tickets for each category. For example:
Total Tickets = COUNTROWS(TicketsTable)
Create a Ranking Measure: Use RANKX to rank the categories by ticket count within each month.
Category Rank = RANKX( ALLSELECTED(TicketsTable[Category]), CALCULATE([Total Tickets]), , DESC, Dense )
Filter for Top 5 Categories: Add a calculated column or use a visual-level filter to limit the data to the top 5 categories:
Is Top 5 = IF([Category Rank] <= 5, 1, 0)
Use this as a filter for your visual, setting Is Top 5 = 1.
Set Up the Visuals:
Let me know if you need assistance implementing these!
Hi @Viperchick007,
There are several methods to get the top 5 categories, Mest way is to get using the DAX, but since this is added under the Power Query will give you that method,
Using Power Query
Sort Data by Ticket Count:
Add a Rank Column:
Filter for Top 5:
Load Data into Power BI:
To show the Top 5 Categories of tickets by individual months in Power BI for a Bar Chart and a Pivot Table, follow these steps:
Create a Measure for Ticket Count: Calculate the total tickets for each category. For example:
Total Tickets = COUNTROWS(TicketsTable)
Create a Ranking Measure: Use RANKX to rank the categories by ticket count within each month.
Category Rank = RANKX( ALLSELECTED(TicketsTable[Category]), CALCULATE([Total Tickets]), , DESC, Dense )
Filter for Top 5 Categories: Add a calculated column or use a visual-level filter to limit the data to the top 5 categories:
Is Top 5 = IF([Category Rank] <= 5, 1, 0)
Use this as a filter for your visual, setting Is Top 5 = 1.
Set Up the Visuals:
Let me know if you need assistance implementing these!
Thank you! I used DAX. It has worked for creating a Pivot Table which displays different categories in each month as opposed to using Top N filter that shows the same categories in each month and I know they should all be different.
I have not found a solution to the bar chart but the table is sufficient for now.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.