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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors