Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am hardcore failing at making TOPN work in DAX instead of the filters on a visual. I have tried and looked at a million different things and ways of doing it in my real data set and this dummy sample I made, and failed at every step of the way, so am giving up for now and seeing if someone can show me what the correct way to do it is.
All I need is the proper DAX to make a measure that will return the TOPN for by Volume for a dummy data set like below.
My latest failure is:
Solved! Go to Solution.
This appears to be the explanation I was looking for. I feel really dumb after seeing it, I blame being tired at the end of a day and week. Will post back in a little after I run it through the real data set.
Update: It works! Only problem having now in the real dataset is when I try to use a measure I have built that spits out what I want the TOPN to be (instead of using an actual number) it's funky and goes from sorting the top 95 when I use 'TOPN(95' to sorting the top 25 when I use 'TOPN([measure]' (but still keeps the total at the bottom of the table as the total of TOP95, but only showing TOP25 items, lol. Gonna do some reading and look into what is up, but I've triple checked the measure and it's spitting out a 95 everywhere else I use it.
If you check the documentation for TOPN (here and/or here), you may notice that it returns a table as its output, not a single value. A measure can only return a single value.
The easiest approach is usually to use the Top N filtering option in the filter pane.
See here too: https://community.powerbi.com/t5/Desktop/TopN/m-p/131646
Yeah, that's the easy way for us people in the office to do it. The goal is to make it go automatically by another measure that I have built to spit out a number for what I want the TOPN to be so on the user side they don't have to do anything and break the report or do god knows what. I wish in that TOPN i nthe filter pane I could just drag in the measure instead of having to manually input the number, but it is what it is.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
9 | |
7 | |
7 | |
6 |
User | Count |
---|---|
21 | |
11 | |
10 | |
9 | |
8 |