Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
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!
Check out the February 2025 Power BI update to learn about new features.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!