Forum Discussion
zalik22
Sep 19, 2023Copper Contributor
Help with sorting Sharepoint List
Hi, I have a sharepoint list that contains a combination of alpha and/or numeric characters. I am trying to sort descending by the numeric portion of the field. Any ideas? Some example values are: AB...
Rob_Elliott
Sep 20, 2023Silver Contributor
zalik22 out of the box you can't sort on just the numeric part of a single line of text column as SharePoint has always sorted it from left to right. You would need separate columns for the numeric and text parts and sort on the number column. You could then have a calculated column that concatenates the text and number columns.
You might not need this but for the number column Num I've ensured it has 3 numbers by formatting it with the following JSON:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=padStart(toString(@currentField),3,'0')"
}
The formula for the Combined column is =CONCATENATE(Txt," ",Num)
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP UK (and classic 1967 Morris Traveller driver)
zalik22
Sep 20, 2023Copper Contributor
Thanks Rob, I don't need to worry about being 3 digits. I already have the field with numeric and text values. Can I create a variable and just put in code to extract the numeric values? How is this possible? I am not very familiar with SharePoint so if you could help me out that would be great!