How to populate an invoice table from the bottom up with only services having associated costs from another Numbers table?

Im looking to have 2 tables. The first table will be a table that allows for costs to be entered, altered or deleted as necessary, and then have those services and associated costs transferred to another table that will populate from the BOTTOM UP with only those services containing a cost associated with them. Likewise, if a cost is added or subtracted, those changes should reflect in the invoice table below.


Is this possible without using an AppleScript? I'm fairly certain I could get it to work with a script, but I'm having a difficult time with the having Numbers exclude items in the Invoice Listing that don't have a cost. I also know filtering will work, but the trouble with filtering is the table collapses from the bottom up and not the top down. Im basically looking to filter the services with a cost without using a filter.


I'm calling on all Apple Numbers Gurus that might be able to help me with this. Much thanks in advance!



[Edited by Moderator]

Original Title: Fill A Table From The Bottom Up With Only Specific Items Having An Associated Cost that Have Been Entered In Another Table

Posted on Sep 23, 2025 2:35 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 24, 2025 11:54 AM

It is possible to do, and you don't need AppleScript - although I agree the 'bottom-up' approach is odd, but it's not my invoice :)


The solution (at least the one I came up with) requires adding two additional columns to your table.


Instead of:



Add a new column for the index order, and a new column for the displayed name, like:



These cells can be hidden after setup, but for now leave them visible.


The formula in cell A2 is:


=IF(B2>0,ROW()−1,0)


This triggers the cell so that it shows the row number (-1 for consistency) when the value in B2 is not zero - if no cost => index value is 0.

Fill this formula down and you'll see the numbers populate for any cell that has a corresponding value.


Now, for cell C2, we do something similar - if the cost is >0 then we copy the SERVICE value:


=IF(B2>0,D2,"")


Now the table populates the 'Displayed' column for any row that has a cost associated with it.


Now we're almost done.


For the magic, we simply grab the array of Cost and Displayed cells from this table and sort it by the index column. Cells that have no value will sort to the top:


Create a new table (or edit the invoice table itself), and set the first cell of the service list to:


=SORTBY(Line Items::B:C,Line Items::A)


This grabs the cells from columns B:C in the 'Line Items' table (or whatever you called it), and sorts it by the values in column A of that same table.


The rows from the source table that have no cost will be sorted first (because their index is 0), and their corresponding Displayed value is also blank:



The last thing to do is format the Cost column so that $0 items are suppressed via a Custom Format



and Viola!


5 replies
Question marked as Top-ranking reply

Sep 24, 2025 11:54 AM in response to Ed M.

It is possible to do, and you don't need AppleScript - although I agree the 'bottom-up' approach is odd, but it's not my invoice :)


The solution (at least the one I came up with) requires adding two additional columns to your table.


Instead of:



Add a new column for the index order, and a new column for the displayed name, like:



These cells can be hidden after setup, but for now leave them visible.


The formula in cell A2 is:


=IF(B2>0,ROW()−1,0)


This triggers the cell so that it shows the row number (-1 for consistency) when the value in B2 is not zero - if no cost => index value is 0.

Fill this formula down and you'll see the numbers populate for any cell that has a corresponding value.


Now, for cell C2, we do something similar - if the cost is >0 then we copy the SERVICE value:


=IF(B2>0,D2,"")


Now the table populates the 'Displayed' column for any row that has a cost associated with it.


Now we're almost done.


For the magic, we simply grab the array of Cost and Displayed cells from this table and sort it by the index column. Cells that have no value will sort to the top:


Create a new table (or edit the invoice table itself), and set the first cell of the service list to:


=SORTBY(Line Items::B:C,Line Items::A)


This grabs the cells from columns B:C in the 'Line Items' table (or whatever you called it), and sorts it by the values in column A of that same table.


The rows from the source table that have no cost will be sorted first (because their index is 0), and their corresponding Displayed value is also blank:



The last thing to do is format the Cost column so that $0 items are suppressed via a Custom Format



and Viola!


Sep 24, 2025 6:23 PM in response to Ed M.

As Camelot showed, while it is possible to fill the table from the bottom, it makes a simple job difficult. Filling from the top would be a simple FILTER function in one cell that "spills" into other rows as needed.


Instead of a bunch of blank rows at the top of the invoice, how about hiding the blank rows using a filter? In the screenshot below, the filter is turned off. If it is on, rows 4-7 will be hidden.



Formula in cell A2 =FILTER(Table 1::A:B,Table 1::B≠0)

The table has three footer rows at the bottom for the calculations.


The other thing from your original tables that adds to the complexity is the columns being swapped. Service and Cost are columns B and A, respectively, in the first table but are A and B in the second. I changed their order in the first table.


One thing not addressed in this example is what you meant by "ignoring any blanks, duplicates, or zero cost items". The formula will filter out blanks and zero cost items but not duplicates (like if you have two or more rows in the first table that are labeled "ceiling" and both have a cost next to them).

Sep 24, 2025 6:40 PM in response to Ed M.

And here is an alternative idea. What I show below is pretty basic but it gives the general idea. The advantage of this one is that you can use Table 1 to enter your costs individually (on separate rows) as they are incurred so you can refer back to what you spent on what (and possibly see if you missed entering something). For instance, you might have ten costs associated with "ceiling" and each will have its own row.


Column A of Table 1 is a column of popup menus of the five services (plus a blank). Click on a popup menu to choose a service then enter a cost and add some notes.


Column A of Table 2 is a list of the five services, typed in.

Column B of Table 2 sums up the costs for each of them.

A filter on Table 2 will hide all rows that are 0. The filter is shown but is not currently on.

Formula in Table 2::B2 =SUMIF(Table 1::A,A2,Table 1::B)

Fill down to row 6 with that formula

Last three rows of Table 2 are footer rows, same as before.


Sep 26, 2025 2:49 PM in response to SGIII

First, thanks to Camelot! Works exactly as I envisioned! You are awesome!


Badunit: Yes, you are correct! I was in fact able to get something to work with a filter, but needed the "bottom up" fill. The problem was that the filter would contract upward leaving the result in a position that was not at a correct physical location on the invoice. I could have probably made another table that mirrored the results in the order that I needed. As far as your alternative, now that's an idea I'm going to mess around with. I like it! The problem still seems to be the location where the totals end up. I need it to be anchored to a specific location on the invoice.


As I mess around with this further, I want to thank everyone that chimed in! SGIII, Yes, I wish I was able to alter the sheet, but my office if funny that way. I have submitted alternatives in the past. However, I will keep trying. Just waiting for some old fogies to retire 🙂

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.

How to populate an invoice table from the bottom up with only services having associated costs from another Numbers table?

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