Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
I want to create a measure to show values only for TOP 5 and Bottom 5 performers together in one table.
I know how to do this with TOPN, but I need to repeat it with RANKX and compare performance as the amount of data is big.
The calculated table in the formula works as expected when I check with a physical table, but I can't make it work when I'm trying to use calculation in a measure.
Here is the formula:
Solved! Go to Solution.
If you insist,
Top and Bottom VirtualTable =
VAR __t = ADDCOLUMNS( ALLSELECTED( DIM_Product[Product CD] ), "@sales", [Sum Sales] )
RETURN
CALCULATE(
[Sum Sales],
KEEPFILTERS(
UNION( TOPN( 5, __t, [@sales] ), TOPN( 5, __t, [@sales], ASC ) )
)
)
But I didn't see any advantage over TOPN() or WINDOW().
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
@ThxAlot I liked this one. I will use this one, much cleaner.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Regardless you have to calculate it twice. 🙂
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Kazanskyi I think you shouldn't worry about if it is getting calculated twice or not, check the performance using the performance analyzer and then decide.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Kazanskyi and here is the output:
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you for your idea, @parry2k
I did something similar with TOPN, but the problem with these solutions is that the table is recalculated 2 times to obtain the output.
With RANKX it should be only 1 iteration that in theory should be faster.
If you have an approach how to do this with one iteration, that would be amazing!
If you insist,
Top and Bottom VirtualTable =
VAR __t = ADDCOLUMNS( ALLSELECTED( DIM_Product[Product CD] ), "@sales", [Sum Sales] )
RETURN
CALCULATE(
[Sum Sales],
KEEPFILTERS(
UNION( TOPN( 5, __t, [@sales] ), TOPN( 5, __t, [@sales], ASC ) )
)
)
But I didn't see any advantage over TOPN() or WINDOW().
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
@Kazanskyi I love new window functions, and tried that to solve it:
Measure =
CALCULATE (
[Total Sales],
KEEPFILTERS (
UNION (
WINDOW (
1, ABS,
5, ABS,
ALLSELECTED ( DIM_Product ),
ORDERBY ( [Total Sales], DESC )
),
WINDOW (
1, ABS,
5, ABS,
ALLSELECTED ( DIM_Product ),
ORDERBY ( [Total Sales], ASC )
)
)
)
)
You can apply further filters if you want, like checking the BLANK product etc.
If you are interested in learning these new functions, check the playlist on my YT channel: https://www.youtube.com/playlist?list=PLiYSIjh4cEx0BDzmo48YIPzw_dIC0Kd95
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 79 | |
| 38 | |
| 31 | |
| 27 | |
| 27 |