Latest Enterprise DNA Initiatives

Power Query Sort Order Not Working (for me)

Hi
This has to be so basic, yet I can’t understand why my sort order in PQ is not adhered to when I change the sort order in my source.

Attached is a sample file.

In PQ - sort order is Exchange then Ticker.
But when I change the sort order in the source, the result isn’t updated.
I can add or change records, no problem, but can’t the sort order to work.

This must be one of the most basic things… I’m sort of embarrassed to post this.

PowerQuerySortNotWorking.xlsx (19.7 KB)

1 Like

@Ericadyson Looks like some kind of bug, I duplicated the query and loaded as a new table and the sort order is as expected.

2 Likes

Yes. I duplicated the query and now PQ is obeying my instructions! I wonder what caused the ‘bug’. Just shows how you have to check EVERYTHING. It was a worry because this was only an example. Thanks a lot for helping me out!

2 Likes

It’s not a bug … Power BI adds the columns to the model as they’re available in PQ, so new PQ columns are added to the end in the Model view; columns that already exist in the Model view are not reordered. If the same column order is desired in Model view as is shown in PQ, I posted a tip a last year on how to achieve this, but, in the end, it’s only a developer thing as the report consumers will see columns in alphabetical order anyway.
Greg

1 Like

Thanks Greg but I’m not sure that we’re talking about the same thing. The issue was column order. The issue was the sort order of data according to the code in PQ.

The original query was OK. But then when I changed the order of source data (say sorted by another column), the data was not reordered according to the sort instruction in PQ.

Regards Erica

I’m missing the issue, then. Can you attach sample PBIX and visual in question for what is currently happening as well as a mockup of the desired outcome you’re looking for?
Greg

Hi Greg… it’s a PQ issue and I attached the spreadsheet. @AntrikshSharma kindly replied. He duplicated the query and somehow when I changed the source sort order, PQ got into action and restored the order as in the PQ.

@Ericadyson ,

I had a similar issue last year when I changed my source data in a few reports. It appears that once the source is changed, you have to re-establish the connection to the sort-order columns. Even though the column names aren’t changing, PQ seems to assume that the new source makes the columns different.

Hi Everyone

I’m closing this. I deleted by query result table and re-ran the query and everything seems to be fine. So I don’t what the initial problem was but I’m up and running. Thanks everyone.

1 Like