Skip to main content

I want to sort 9 fields of numbers on a single row and order them into 9 new fields on the same row that show the numbers from lowest to highest. If the old fields are labeled #1-#9 and the new fields are labeled A,B,C,D,E,F,G,H,I, then I want to search #1-9, find the lowest, and put it in A, then search #1-9 for the next lowest and put it in B and so on.

I’m not sure if I need to write an automation with code, a script, or what, but the base features of Airtable do not seem to be able to handle this.

Ok should definitely have reworded the title as now I can’t seem to change it. Not exactly an accurate title and can’t delete the post either :/

 


Hm yeah best bet’s a script I think.  You could probably try to do it with a formula, but i think it’d get super complicated and wouldn’t be worth the effort, really


It might be possible to do this with formulas, but it would get too complicated. I suggest writing a script instead.

Let me know if you need any help with the script.

Taha, Airtable Advisor


I was thinking of trying to do it in excel after exporting from airtable. it isn’t the end of the world as long as its an automated process. I have no scripting experience. I need to hire someone or get help.


I could offer something like $50-75 for the job. Not much. But it’s also something a pro could do fairly quickly I would think.


Hey ​@epicmike2835,

I tested out this script and it works! You can copy-and-paste this script into the Scripting extension and click run (after you select the table). Let me know if there’s any issues.

let config = input.config({
title: "Select Table",
description: "Choose the table where you want to create fields #1–#9 and A–I.",
items:
input.config.table("table", { label: "Table" })
]
});
// Get the active table
let {table} = config;
let numberFields = i"#1", "#2", "#3", "#4", "#5", "#6", "#7", "#8", "#9"];
let sortedFields = i"A", "B", "C", "D", "E", "F", "G", "H", "I"];
let allFields = i...numberFields, ...sortedFields]


// Get all records
let result = await table.selectRecordsAsync({fields: allFields});

// Loop through each record
for (let record of result.records) {
// Read the values of #1 to #9
let numbers = numberFields.map(field => record.getCellValue(field));

// Skip record if any of the numbers are missing or not numeric
if (numbers.some(n => typeof n !== "number")) {
console.log(`Skipping record ${record.id} due to missing or non-numeric values.`);
continue;
}

// Sort numbers from lowest to highest
let sorted = o...numbers].sort((a, b) => a - b);

// Map sorted values to new fields A through I
let updates = {};
sortedFields.forEach((field, index) => {
updates field] = sorted=index];
});

// Update the record
await table.updateRecordAsync(record, updates);
}


Would it also be possible for you to describe more about the larger context of what you want to accomplish with this? Because maybe there’s a more organized way of doing what you want to do. 🙂


You can achieve this in Airtable using a script in the Scripting extension, especially since sorting across fields horizontally isn’t a native feature. If you're interested in gathering user input effectively in your own tools or forms, you might want to look into how user experiences are evaluated through structured feedback like the Canes customer experience to inspire your approach. Scripts can really help automate and streamline data handling similar to such use cases.

 

 


Does this look right?

If so, I’ve sent you a DM with a link to the base with the script in it.  You’ll need to modify it to match your own base (update the table and field names etc) but it should be fairly forward; hit me up if you need some help with it!