Power BI Top N Table: Step-by-Step Guide
In this article
To create a Top N table in Power BI, you use a visual-level filter or a DAX measure to rank and filter your data, then display it in a table or matrix visual. The quickest method is to add a table visual, drag your category field and value field into it, then apply a Top N filter on the category field. This guide walks you through both the filter approach and a dynamic DAX approach so you can choose what fits your report.
What You'll Need
- Power BI Desktop (or Power BI service with edit permissions) installed and signed in.
- A dataset loaded into your report with at least one category column (e.g., Product, Customer) and one numeric value column (e.g., Sales, Revenue).
- Basic familiarity with the Fields pane and Visualizations pane.
- For the DAX method: a willingness to write a simple measure and use a slicer or parameter.
Menu labels and visual names can differ slightly between Power BI Desktop versions, the Power BI service, and regional settings. The steps below are written for Power BI Desktop; the service is very similar but some right-click options appear in different places.
Step-by-Step
Method 1: Using the Visual-Level Top N Filter (Static)
- Open your report in Power BI Desktop and select the blank canvas area where you want the table.
- In the Visualizations pane, click the Table visual icon (or Matrix if you need grouping). A blank table appears on the canvas.
- In the Fields pane, drag your category field (e.g., Product[ProductName]) into the Columns well of the visual. Then drag your numeric value field (e.g., Sales[SalesAmount]) into the Values well. The table now shows all categories and their totals.
- With the table visual selected, open the Filters pane (usually on the right side, or via the View ribbon if hidden).
- Under Filters on this visual, you should see your category field listed. Expand it by clicking the small arrow.
- In the Filter type dropdown, choose Top N.
- Set Show items to Top and enter the number you want (e.g., 10).
- In the By value dropdown, select the numeric field you added to the visual (e.g., SalesAmount). This tells Power BI to rank categories by that value.
- Click Apply filter. The table now shows only the top N categories by the chosen value.
- To sort the table so the largest appears first, click the column header of the numeric value once or twice until the down-arrow (descending) appears.
This method is static: the Top N number is fixed unless you edit the filter. It works well for dashboards where the ranking does not need to change interactively.
Method 2: Dynamic Top N with a What-If Parameter
- In Power BI Desktop, go to the Modeling ribbon and click New parameter > Numeric range.
- Name it something like TopN, set Minimum to 1, Maximum to 50, Increment to 1, and Default to 10. Click Create. This adds a slicer to the canvas automatically.
- Create a measure that ranks your categories. For example, if your table is Sales with column Product and measure Total Sales , write: (Adjust table and column names to match your model.)
- Add a new measure to filter based on the parameter:
Top N Sales = IF([Rank] <= [TopN Value], [Total Sales], BLANK())
Replace [TopN Value] with the name of the parameter measure (often the same as the parameter name). - Build a table visual with Product in Columns and Top N Sales in Values.
- In the Filters pane for the visual, drag the Top N Sales measure into the filter well and set it to is not blank. This hides categories outside the top N.
- Use the slicer to change N interactively. The table updates to show only the top N products by sales.
This approach is more flexible but requires DAX knowledge. If you are new to DAX, start with Method 1.
Common Mistakes
- Forgetting to set the "By value" field in the Top N filter. Without it, Power BI may rank by the category name alphabetically instead of by your numeric measure.
- Using a column instead of a measure in the By value dropdown. If your numeric field is a column (e.g., a calculated column), it may not aggregate correctly. Prefer explicit measures.
- Applying the filter to the wrong field. The Top N filter must be on the category field (the one you want to rank), not on the value field.
- Expecting the table to sort automatically. Top N filters the rows but does not guarantee order. Always sort the value column descending.
- Using a visual-level filter when you need a page-level or report-level filter. Visual-level filters only affect that visual; if you have multiple visuals, you may need to apply the filter at the page level or use a measure.
- Ignoring ties. If two categories have the same value at the Nth position, Power BI may include both or neither depending on the filter settings. Check the "Show items when the value is" options if ties matter.
Tips
- Use a measure for the value field in the Top N filter to ensure correct aggregation across filters.
- If you need the Top N to respect other slicers (e.g., date range), the visual-level filter does this automatically. The DAX RANKX approach also respects filter context if written correctly.
- For a cleaner look, add a title to the table visual that includes the N value, e.g., "Top 10 Products by Sales". You can make it dynamic by using a measure in the title.
- Test with a small N first (e.g., 3) to verify the ranking is correct before scaling up.
- Remember that Top N filters apply after other filters. If you have a filter on the same field, the Top N will operate on the filtered set.
Troubleshooting
- The Top N filter option is greyed out or missing: Ensure the field you are trying to filter is in the visual's Columns or Rows well, not just in Values. Top N is only available for fields that define the granularity of the visual.
- The table shows all rows despite the filter: Check that the filter is applied to the correct visual and that you clicked "Apply filter". Also verify that the filter is not being overridden by a page-level or report-level filter.
- The ranking looks wrong: Confirm the "By value" field is the correct measure and that the measure is not affected by unexpected filter context. Try creating a simple SUM measure to test.
- The DAX measure returns blanks for all rows: Check that the RANKX measure references the correct table and column, and that the parameter measure name is correct. Use the DAX editor's syntax checking.
- The slicer does not change the table: Ensure the slicer is connected to the parameter (it should be automatically) and that the measure uses the parameter value. Also check that the visual-level filter on the measure is set to "is not blank".
- Performance is slow with large datasets: Top N filters can be resource-intensive. Consider aggregating data beforehand or using a summary table. For the DAX method, optimize RANKX by using ALLSELECTED instead of ALL if appropriate.
Frequently Asked Questions
Can I make the Top N number change with a slicer without DAX?
No, the visual-level Top N filter requires a fixed number. For a dynamic N, you need a What-If parameter and a DAX measure as described in Method 2.
Does the Top N filter work on a matrix visual?
Yes, you can apply a Top N filter to a matrix visual the same way. However, the ranking applies to the row or column field you filter on, so ensure you select the correct field.
What happens if there are ties at the Nth position?
Power BI includes all items that tie for the Nth value by default. You can change this behavior in the filter settings by choosing "Show items when the value is" and selecting "Top N" with the "Include ties" option.
Can I show the Top N and also an "Others" category?
Not directly with the Top N filter. You would need to create a calculated table or use DAX to group the remaining items into an "Others" category. This is more advanced and typically requires a separate measure or table.
Why does my Top N table show fewer rows than N?
This can happen if there are fewer distinct categories than N, or if some categories have blank values that are excluded. Check your data for blanks and ensure the value field is not blank for those rows.
Does the Top N filter respect other slicers on the page?
Yes, visual-level filters are applied after other slicers and filters, so the Top N ranking is calculated on the filtered data. This is usually the desired behavior.