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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ep11
Frequent Visitor

Delete sorting in final Dax Query

I have a pbix project. Through the perfomance analyzer, I was able to get Dax Query that my project generates and discovered an interesting thing. In my project does not contain any sorts. For some reason they are in the Dax Query:

 

 

// DAX Query
DEFINE
VAR __DS0FilterTable =
FILTER(
KEEPFILTERS(VALUES('Table_Name'[col_date])),
AND(
'Table_Name'[col_date] >= DATE(2021, 3, 1),
'Table_Name'[col_date] < DATE(2021, 7, 1)
)
)

VAR __DS0Core =
SUMMARIZECOLUMNS(
ROLLUPADDISSUBTOTAL(
ROLLUPGROUP(
'Table_Name'[col_vachar1],
'Table_Name'[col_vachar2]
), "IsGrandTotalRowTotal"
),
__DS0FilterTable,
"Sum", CALCULATE(SUM('Table_Name'[NewQty]))
)

VAR __DS0PrimaryWindowed =
TOPN(
502,
__DS0Core,
[IsGrandTotalRowTotal],
0,
'Table_Name'[col_vachar1],
1,
'Table_Name'[col_vachar2],
1
)

EVALUATE
__DS0PrimaryWindowed

ORDER BY
[IsGrandTotalRowTotal] DESC,
'Table_Name'[col_vachar1],
'Table_Name'[col_vachar2]

 

 

I tried removing the last four lines of the query and running it. The request completed 25% faster. Is there any way to make my pbix project not use this sort? Is it possible through Power BI Desktop to edit the final Dax query that the project generates?

3 REPLIES 3
ep11
Frequent Visitor

I made a new project for testing, it also has sorting.

Created a simple table:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIyMDI0AEIg0xGIDQ2AhFKsTrSSEULSCCppBJc0RpV0AmJjuKQJQhKkzhmITeCSppiSphDJWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}, {"Column3", type text}, {"Column4", Int64.Type}, {"Column5", type text}})
in
#"Changed Type"

 

For visualization included only these columns:

ep11_0-1649920666854.png

 

As a result, in the Dax query I see sorting

// DAX Query
DEFINE
  VAR __DS0Core = 
    SUMMARIZECOLUMNS(
      ROLLUPADDISSUBTOTAL('Table'[Column3], "IsGrandTotalRowTotal"),
      "SumColumn4", CALCULATE(SUM('Table'[Column4]))
    )

  VAR __DS0PrimaryWindowed = 
    TOPN(502, __DS0Core, [IsGrandTotalRowTotal], 0, 'Table'[Column3], 1)

EVALUATE
  __DS0PrimaryWindowed

ORDER BY
  [IsGrandTotalRowTotal] DESC, 'Table'[Column3]

 

Is there a way to avoid using this sort? Or is it required for data grouping? Sorting takes a long time on large amounts of data

ep11
Frequent Visitor

>>This Dax for you visual?
Yes, example with renamed columns

 

Visually I have disabled all sorting

ep11_2-1649918922765.png

 

amitchandak
Super User
Super User

@ep11 , This Dax for you visual?

 

can you check visual has no sorting?

 

I doubt you can force your own DAX.

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

Top Solution Authors
Top Kudoed Authors