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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
bogdan_elastic
New Member

Sorting by non-grouped column

Hi there,

I'm looking for some guidance or hint on the below case I'm trying to solve.

I'm working on an ODBC-based connector for a SQL datasource that lacks currently the capacity to sort/order by non-groupped columns.

In case DirectQuery is enabled, PowerBI will generate statements of the (simplified) type:

select a from (select a, b, c, d from table group by a, b) order by c, d

(below the actual null-handling sorting query). To this the datasource complains that it "[c]annot order by non-grouped columns".

There seems to be no capability in the ODBC spec to indicate support (or lack of) for this type of query. The AstVisitor functionality seems unfit for this case.

I was wonding if there's any way to indicate this incapacity to PowerBI?

 

Thanks in advance for any hint!

--b

Actual statement submitted for preparation:

select "date0"
from
(
   select "date0",
       "C1",
       case
           when "C1" is not null
           then "C1"
           else ?
       end as "C2",
       case
           when "C1" is null
           then ?
           else ?
       end as "C3"
   from
   (
       select "date0",
           "date0" as "C1"
       from "calcs"
   ) as "ITBL"
   group by "date0",
       "C1"
) as "ITBL"
order by "ITBL"."C2",
       "ITBL"."C3"

 

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hi @bogdan_elastic 

 

Would you be able to visualize your problem, as a sample of data in the current state and what is the outcome that you expect?

Please, can you clarify, what do you mean by "I was wonding if there's any way to indicate this incapacity to PowerBI?"

 
Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
Mariusz Repczynski

 

 

Hi @Mariusz ,

 


Would you be able to visualize your problem, as a sample of data in the current state and what is the outcome that you expect?

Please, can you clarify, what do you mean by "I was wonding if there's any way to indicate this incapacity to PowerBI?"

I am looking for a way to flag to PowerBI that the data source can't order by a column, if that column is not used for grouping.

Ideally, there would be a setting in SqlCapabilities passed to Odbc.DataSource, as an example.

 

So, in the full example I've given, ideally PowerBI would also group by "C2" and "C3" if ordering by these columns.

 

Regards,

Bogdan.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.