PQ Sort Error

RattlingCarp3048

Board Regular
Joined
Jan 12, 2022
Messages
202
Office Version
  1. 365
Platform
  1. Windows
I've been stuck on this for a while. it seems so simple but i just cannot get pass it. In the PQ Editor, column A was/is a custom column formatted as text and is an alpha-numeric set of data. When i load the data in excel there are no blanks or errors and sorts perfectly but for some reason column A will not sort in the editor ascending or descending. I tried removing blanks and removing errors just in case i missed something but it still will not sort. The source data was copy/pasted so there are no additional connections or queries. Any ideas???

1719341375636.png
1719341470857.png
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Is the original source of the "Accession # & Block" column formatted correctly from source to "Accession #" usage?

I would suggest the following:
1. Make sure the original column that is brought in from your source file is formatted to Text.
2. In this Accession # column, you may need to make sure to keep your text a text as it may be changing the format when you perform that Text.Start.
Before
Power Query:
=if Text.Contains([#"Accession # & Block"]," ") then Text.Start([#"Accession # & Block"], Text.PositionOf([#"Accession # & Block"]," ")) else [#"Accession # & Block"]
After
Power Query:
=if Text.Contains([#"Accession # & Block"]," ") then Text.Start([#"Accession # & Block"], Number.ToText(Text.PositionOf([#"Accession # & Block"]," "))) else [#"Accession # & Block"]
3. Once you complete the updating of the update of the Accession # Custom Column, make sure that at the end in the formula bar at the top of PQ Edition with ", type text". So your whole line of M Code should read like this
Power Query:
= Table.AddColumn(#"Previous Step", "Accession #", each if Text.Contains([#"Accession # & Block"]," ") then Text.Start([#"Accession # & Block"], Number.ToText(Text.PositionOf([#"Accession # & Block"]," "))) else [#"Accession # & Block"], type text)
4. Then try out your sort.
 
Upvote 0
Solution
Is the original source of the "Accession # & Block" column formatted correctly from source to "Accession #" usage?

I would suggest the following:
1. Make sure the original column that is brought in from your source file is formatted to Text.
2. In this Accession # column, you may need to make sure to keep your text a text as it may be changing the format when you perform that Text.Start.
Before
Power Query:
=if Text.Contains([#"Accession # & Block"]," ") then Text.Start([#"Accession # & Block"], Text.PositionOf([#"Accession # & Block"]," ")) else [#"Accession # & Block"]
After
Power Query:
=if Text.Contains([#"Accession # & Block"]," ") then Text.Start([#"Accession # & Block"], Number.ToText(Text.PositionOf([#"Accession # & Block"]," "))) else [#"Accession # & Block"]
3. Once you complete the updating of the update of the Accession # Custom Column, make sure that at the end in the formula bar at the top of PQ Edition with ", type text". So your whole line of M Code should read like this
Power Query:
= Table.AddColumn(#"Previous Step", "Accession #", each if Text.Contains([#"Accession # & Block"]," ") then Text.Start([#"Accession # & Block"], Number.ToText(Text.PositionOf([#"Accession # & Block"]," "))) else [#"Accession # & Block"], type text)
4. Then try out your sort.
thank you so much. this seemed to have worked :)
 
Upvote 1

Forum statistics

Threads
1,223,898
Messages
6,175,272
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top