Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
cuongle
Advocate II
Advocate II

Power BI - Select top N in "Direct Query" mode

In "Import Data" mode, it would be easy for us to use DAX `RANKX` in order to support TOP N:

 

SupplierRank = IF(HASONEVALUE('Supplier'[name]), 
			RANKX(ALLSELECTED('Supplier'), [SumSpend],, DESC), 
			BLANK()
		)

 

And then we can choose SupplierRank <= 10 on Visual level filter, but on "Direct Query" mode, Power BI desktop prevents to use `RANKX` due to performance. Is there any workaround on "Direct Query" mode.

2 REPLIES 2
ankitpatira
Community Champion
Community Champion

@cuongle Are you using SQL data source then it would be easier to input sql query at the connection time to limit number of rows returned by donig select top(*), if you're using any other data source then also it would be easy to create index column in data source itself rather than trying in pbi desktop as it has restricted feature in DirectQuery mode.

Anonymous
Not applicable

@ankitpatira

 

It wouldn't be possible to construct an index column on the data source in my case. We have multiple filters on the dashboard and the top N should be on the basis of selections made by the user. The data source is huge ( more than 100 million rows for just one view that holds the fields on which it need to be filtered and ranked).

 

What approach would you suggest?

 

If there is any DAX that you can share, please share it so I can try if it works on the data set.

 

@cuongle it would be nice if you can share the approach you took, if you went ahead with the implementation.

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors