Shortcut to create a dynamic formula in Numbers

I have created a shortcut that add a record to the end of a Numbers table. I would like to add this formula to one of the columns IF(B65="Ending",C65−C64,0). I can get the formula added to the table but it acts as a text field and not a formula. How do I get Numbers to recognize it as a formula? Also, the rows will be different every time so how do I determine the current row in a shortcut?


Thanks in advance.

Posted on Jan 2, 2025 10:09 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 3, 2025 2:53 PM

Put an = at the front of it. When it is inserted into the cell it becomes a formula.


I do not see anything in Shortcuts that will tell you the row, other than writing a short AppleScript that spits it out or spits out the full text of the formula. A different way to write your formula that does not require the row to be known is to use INDEX, ROW, and some "whole column" addressing. If the row you are inserting is row 65 then instead of

=IF(B65="Ending",C65−C64,0)

use

=IF(B="Ending",C−INDEX(C,ROW()−1),0)


The B and the first C in this formula refer to the cells in the same row as the formula (B65 and C65) because Numbers is expecting a single cell/value, not a range, for that data. The second C is the entire column because Numbers expects that parameter to be a range. ROW() will be 65 so INDEX(C,ROW()-1) will be cell C64

6 replies
Question marked as Top-ranking reply

Jan 3, 2025 2:53 PM in response to josephfromwallagrass

Put an = at the front of it. When it is inserted into the cell it becomes a formula.


I do not see anything in Shortcuts that will tell you the row, other than writing a short AppleScript that spits it out or spits out the full text of the formula. A different way to write your formula that does not require the row to be known is to use INDEX, ROW, and some "whole column" addressing. If the row you are inserting is row 65 then instead of

=IF(B65="Ending",C65−C64,0)

use

=IF(B="Ending",C−INDEX(C,ROW()−1),0)


The B and the first C in this formula refer to the cells in the same row as the formula (B65 and C65) because Numbers is expecting a single cell/value, not a range, for that data. The second C is the entire column because Numbers expects that parameter to be a range. ROW() will be 65 so INDEX(C,ROW()-1) will be cell C64

Jan 3, 2025 9:33 AM in response to Yellowbox

My questions:

  • What is your overall aim? log business miles based on starting and ending odometer readings.
    • columns are date, starting / ending, odometer reading, total miles, comments
    • e.g. 1/2/2025 Starting 205000 0 travel to customer
    • e.g. 1/3/2025 Ending 205200 200 <no comments>. Note: the 200 is I want the calculation to be.
  • How does "Ending" arrive in the last cell of a column? Short cut adds a new row to the bottom of the table
  • Is "Ending" in the very last (bottom) cell of your table? Or are there blank rows below? no blank rows below
  • Does your table have a Footer Row? No


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Shortcut to create a dynamic formula in Numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.