Forum Discussion
powerquery sort based on two columns
Sort by the first column. Sort by the second column. You will see little numbers appear
Or you can do it in code.
Note: Sorting in Power Query is a red flag/code smell. In the vast majority of cases you do not need/want to sort your data in Power Query.
Can you explain shortly why it is not a good idea to sort data in PQ ?
- PhilippeMuniesa3 years agoResolver I
Yes, i'm interested too.
And in my project, i need sort tables because thay are not read in order and for the transformations, i need to get table sorted by date and by item.
Sincerly
Philippe
- bourquejeff19751 year agoNew Member
Hi! I'm not sure why PQ strips out sorting when merging queries sometimes, but the fix is this:
- After sorting the columns, click on the "fx" button in the formula bar (on the left)
- Put the code after the "=" in parenthesis, and add the "Table.Buffer" function in front
Example:
= Table.Buffer(#"Sorted Rows1")
This somehow makes the sorting "stick" no matter what else you do.