Forum Discussion

iplaygod's avatar
iplaygod
Resolver I
8 years ago
Solved

Problem with sort order changing after load into model

I have a problem that is related to sort order. Its driving me crazy. cant figure it out.   I have an access db in file format. A table contains approx 2 million rows of data. Each row has a Row ID...
  • OwenAuger's avatar
    8 years ago

    Hi iplaygod

     

    The Vertipaq engine applies a number of compression algorithms to reduce the memory footprint of a Power BI data model.

    See here for a good description.

     

    In your example, it could be Run Length Encoding that is resulting in a reordering of your table's rows. With Run Length encoding, a column with a large number of repeated values is sorted so that equal values are grouped together. This means rows containing a common value can be internally referred to by start position & run length.

     

    For this reason, you can never rely on a particular sort order of rows in a Power BI model.

    By and large, there is almost no way in DAX to write a useful expression that depends on the order of a table's rows (exceptions may be the SAMPLE function and the undocumented TOPNSKIP function). I would always determine "order" from the values contained in one or more columns.

     

    In the Data view, you can sort by a particular column by right-clicking on a column header, which might meet your needs. I'm not sure whether this is cosmetic or actually changes the sort order of the in-memory table.

     

    Regards,

    Owen