Forum Discussion

Powerwoman's avatar
Powerwoman
Icon for Helper II rankHelper II
2 years ago
Solved

Sorting in Power Query isn't applied to Desktop???

Hi there,
this is driving me crazy.

In Powerquery I created a sort order based on 2 different columns and afterwards I created an index column.

It's working fine with my test Excel but when connecting to SQL I'm completely loosing the sorting in Desktop.

Already tried to enable / disable 'enable load', save it, cleared cache, restarted Power BI Desktop, duplicate the query...

Any ideas are highly appreciated!

  • Solved the problem myself...
    I used the advanced options provided by the SQL Connector:

     

     

     

8 Replies

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    Do you mean the data isn't sorted once it is loaded to powerbi front end (i.e. viewing it in Table view)? or the index is not created properly because Power Query sorting is not working?

    • Powerwoman's avatar
      Powerwoman
      Icon for Helper II rankHelper II

      Hi, 
      it's not loaded correctly into the power bi front end (table view).
      As I'm using measure function like earlier etc.. I need it to be sorted in a certain order. 
      Thanx

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    What does "loaded correctly" mean? The index is created correctly but it doesn't display in order?

    • Powerwoman's avatar
      Powerwoman
      Icon for Helper II rankHelper II

      The index is created, but it in the table view it doesn't start at 0 but 44000.... 

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    OK, still not quite clear.  Is the index created correctly for the sorted data in Power Query and this is purely a display issue in table view?

    OR the index is created when the data is not correctly sorted in Power Query and therefore the data rows have incorrect index values?

    --

    There is no specific ordering in table view.  This is controlled by factors behind-the-scenes and cannot be depended on.  This should not affect measures as an index/date field can be used for cumulative measures.

    • Powerwoman's avatar
      Powerwoman
      Icon for Helper II rankHelper II

      Hi,
      I'm using a measure that has a running total using the index.

      RunningTotal2 =
      CALCULATE(
          sum(fact_valueEntriesInbound[Item Ledger Entry Quantity]),
          fact_valueEntriesInbound[Index] <= max(fact_valueEntriesInbound[Index])
      )
       
      When I'm trying to use it in a visual performance  is really bad (+ 10 Min), this is the context I'm using.

       

      My theory is that the measure isn't working because the index column is not sorted correctly?
      Wh does is start at 44700, not at 0 in the dataset? 

       

       

  • Solved the problem myself...
    I used the advanced options provided by the SQL Connector: