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
deepak_d03
Helper I
Helper I

DAX query - Sorted incorrectly

Data set (Table name - Table1) has the insurance complaints inforamtion. I am trying to get the top 10 days where maximum complaints have been filed. 

 

Below is the DAX query result. Its not sorted correctly. Can anyone tell what going wrong?

 

TOPN(
        10,
        SUMMARIZECOLUMNS(
            Table1[Received date],
            "Complaint Count", COUNTROWS(Table1)
        ),
        [Complaint Count],
        DESC
    )
 
1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

TOPN does not guarantee any sort order for the results.

 

If you're writing a DAX query, you can add and ORDER BY clause at the end. For example, 

 

EVALUATE
TOPN (
    10,
    SUMMARIZECOLUMNS (
        Table1[Received date],
        "Complaint Count", COUNTROWS ( Table1 )
    ),
    [Complaint Count], DESC
)
ORDER BY [Complaint Count] DESC

 

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

TOPN does not guarantee any sort order for the results.

 

If you're writing a DAX query, you can add and ORDER BY clause at the end. For example, 

 

EVALUATE
TOPN (
    10,
    SUMMARIZECOLUMNS (
        Table1[Received date],
        "Complaint Count", COUNTROWS ( Table1 )
    ),
    [Complaint Count], DESC
)
ORDER BY [Complaint Count] DESC

 

That worked. Thanks. 

If I need to show this in report view,  how do I do that? 

Then you probably don't need any DAX. Just put the columns in a table visual, add a TopN filter in the filter pane, and sort by whichever one you want.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.