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

Join 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.

Reply
subhendude
Microsoft Employee
Microsoft Employee

Using TOPN DAX query

I have a very basic table with a column latency. The latency stores the time it takes to execute in milliseconds.

 

I would like to see the top 20 records w.r.t the latency column in ascending order. Can anyone help me with the DAX query? I used the following one but the ordering is incorrect.

 

EVALUATE
TOPN (
    20,
    FILTER (
        Fact_APIData_Weekly,
        Fact_APIData_Weekly[ExecutionDate]
            = DATE ( 2022, 4, 23 )
    ),
    Fact_APIData_Weekly[Latency], TRUE
)

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@subhendude , Try like, what is the issue you are getting

 

TOPN (
20,
FILTER (
Fact_APIData_Weekly,
Fact_APIData_Weekly[ExecutionDate]
= DATE ( 2022, 4, 23 )
),
Fact_APIData_Weekly[Latency], desc
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @subhendude ,

 

As far as I know, there is no reliable way. You could click the filter drop down arrow on the column and select Sort.

 

Best Regards,

Jay

subhendude
Microsoft Employee
Microsoft Employee

@amitchandak 

The data is not getting sorted. The backend data is stored in Azure Data Explorer and I've used Power Query to prepare the data model. There is a date dimension table and fact table with latency numbers. I joined both the tables with the date column(one to many relationship)

Then I connect the PBI model with DAX studio and used the above DAX query. Unfortunately it gave me 20 records but not sorted by latency number.

amitchandak
Super User
Super User

@subhendude , Try like, what is the issue you are getting

 

TOPN (
20,
FILTER (
Fact_APIData_Weekly,
Fact_APIData_Weekly[ExecutionDate]
= DATE ( 2022, 4, 23 )
),
Fact_APIData_Weekly[Latency], desc
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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 Kudoed Authors