Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Create an automatic function in Numbers for Mac

Hello the community !


After a search (without success...) for a solution I turn to you!


For my accounting I have a table for each month with 5 columns QUAND–WHEN (date) / QUOI–WHAT / COMBIEN–HOW MUCH (€) / COMMENT–HOW (drop down menu) / FRAIS–EXPENSES (drop down menu) and I would like to make an annex table to account for expenses. (see attached image).

Something that would tell Numbers to go into Sheet 1 "Accounting" -> in the table "JUIN" -> all the rows marked with "Bouche (frais)" (blue) in the 5th column -> and total the values in € of the 3rd box of all these rows?

I'm not sure if I'm clear, I'm quite a beginning on Apple Numbers.


Thanks in advance to anyone who can help me out !


Guillaume




MacBook Pro 15″, macOS 10.15

Posted on Jul 15, 2021 4:30 AM

Reply
Question marked as Best reply

Posted on Jul 16, 2021 5:05 AM

I made the following changes:

  1. Created another sheet, which I named JUIN and moved the JUIN table to it. I recommend you create an empty version of that sheet/table as a template that you can duplicate for new months: Duplicate the JUIN sheet, clear all the data out of the table so it is fresh for a new month, and rename it something bland. Duplicate this "template" for the rest of the months. You can do them all now or do them as you go along.
  2. Renamed the first sheet to SALAIRES
  3. Un-merged the cells in rows 2, 7, 12, 17, 22, and 23. I removed the remaining borders so it looks the same. Merged cell can make tables hard to work with so use them only when absolutely necessary.
  4. Selected all of column B and C and changed the cell format to automatic (was text) so I could insert formulas.
  5. Put a formula in cell B10 and copy/pasted it to C10 then copy/pasted both to the other rows that needed them.
  6. Put a SUM formula in your quarterly totals cells.


The main formula in column B is this:

=IFERROR(SUMIF(INDIRECT($A&"::"&$A&"::F"),B$1,INDIRECT($A&"::"&$A&"::D")),"")

Broken down into its parts,

  • INDIRECT($A&"::"&$A&"::F") creates a cell/range reference from the string of text given to it. We are creating that string by concatenating a few pieces together. In this formula, $A means the cell in this row in column A. It has "JUIN" so the concatenated string becomes "JUIN::JUIN::F" which is all of column F of the JUIN table on the JUIN sheet.
  • INDIRECT($A&"::"&$A&"::D") is the same as above except it is column D
  • SUMIF(where to look, what to look for, sum values) we gave it JUIN::JUIN::F as where to look. We gave it cell B1 as what to look for, which has "Bouche (frais)", and JUIN::JUIN:D is the column of values to sum.
  • IFERROR(..., "") surrounds the whole thing because if there is no "JUIN::JUIN" sheet and table, the function will throw an error. We replace that error with a null string "". The month of JUIN is okay because that one does exist but the other months do not. Those functions are all errors. When you create the sheets/tables for the other months, the formulas will start to work and will give you numbers.
  • The formula is written with some "absolute" addressing (the $ symbols) so the formula can be copy/pasted to the other rows and columns and the correct cells will continue to be referenced. If you add a new column to search for something another category, you should be able to copy/paste the formula into that column.




Similar questions

6 replies
Question marked as Best reply

Jul 16, 2021 5:05 AM in response to Guillaume_André

I made the following changes:

  1. Created another sheet, which I named JUIN and moved the JUIN table to it. I recommend you create an empty version of that sheet/table as a template that you can duplicate for new months: Duplicate the JUIN sheet, clear all the data out of the table so it is fresh for a new month, and rename it something bland. Duplicate this "template" for the rest of the months. You can do them all now or do them as you go along.
  2. Renamed the first sheet to SALAIRES
  3. Un-merged the cells in rows 2, 7, 12, 17, 22, and 23. I removed the remaining borders so it looks the same. Merged cell can make tables hard to work with so use them only when absolutely necessary.
  4. Selected all of column B and C and changed the cell format to automatic (was text) so I could insert formulas.
  5. Put a formula in cell B10 and copy/pasted it to C10 then copy/pasted both to the other rows that needed them.
  6. Put a SUM formula in your quarterly totals cells.


The main formula in column B is this:

=IFERROR(SUMIF(INDIRECT($A&"::"&$A&"::F"),B$1,INDIRECT($A&"::"&$A&"::D")),"")

Broken down into its parts,

  • INDIRECT($A&"::"&$A&"::F") creates a cell/range reference from the string of text given to it. We are creating that string by concatenating a few pieces together. In this formula, $A means the cell in this row in column A. It has "JUIN" so the concatenated string becomes "JUIN::JUIN::F" which is all of column F of the JUIN table on the JUIN sheet.
  • INDIRECT($A&"::"&$A&"::D") is the same as above except it is column D
  • SUMIF(where to look, what to look for, sum values) we gave it JUIN::JUIN::F as where to look. We gave it cell B1 as what to look for, which has "Bouche (frais)", and JUIN::JUIN:D is the column of values to sum.
  • IFERROR(..., "") surrounds the whole thing because if there is no "JUIN::JUIN" sheet and table, the function will throw an error. We replace that error with a null string "". The month of JUIN is okay because that one does exist but the other months do not. Those functions are all errors. When you create the sheets/tables for the other months, the formulas will start to work and will give you numbers.
  • The formula is written with some "absolute" addressing (the $ symbols) so the formula can be copy/pasted to the other rows and columns and the correct cells will continue to be referenced. If you add a new column to search for something another category, you should be able to copy/paste the formula into that column.




Jul 15, 2021 8:52 AM in response to Guillaume_André

For a beginning spreadsheet, this is a little complicated to explain. What you want to do is more complicated than a beginner formula. SUMIF and similar functions are a step or two above beginner. Using INDIRECT to create a cell reference is a step or more above that.


I assume the table on the right is one single table and you set some borders to "no border". I see also that you added a column to the JUNE table. Now the text to look for is in F and the numbers to sum are in D.


You need to be able to give the function the information it needs.

  1. The month name in column A must be exactly the same as the name of the table you want to look in. You have "JUIN" in column A but the actual table is named "JUNE". That won't work. You will have to choose one or the other. I used JUNE but either will work.
  2. You need to specify what text to look for so it can sum the matching numbers. In row 1 of "Salaries" you have "Total frais de Bouche" but the text you are looking for is "Bouche (frais)". The common word between them is "Bouche". We can make that into "Bouche (frais)" in the formula. I inserted a new row 2 in the Salaries table for just the word "Bouche". I set the border between rows 1 and 2 to "no border" so it looks like one row.


The formula in column B is

=SUMIF(INDIRECT("Accounting::"&$A&"::F"),B$2&" (frais)",INDIRECT("Accounting::"&$A&"::D"))





Jul 15, 2021 7:16 AM in response to Guillaume_André

I do not know exactly what you are looking to do. I feel it is a deeper question than what was asked. Here is a shot at answering it:



I have a table named "June" on sheet "Accounting" that is arranged like the table in your screenshot. It has a few rows of data in it.


In the table shown above, the information in columns A and B is entered by hand (or with pop up menus).

C2 =SUMIF(INDIRECT("Accounting::"&B2&"::E"),A2,INDIRECT("Accounting::"&B2&"::C"))


The month name in column B must match letter-for-letter the name of the table you wish to access.

Jul 15, 2021 7:53 AM in response to Badunit

Hello Badunit and thank you very much for you answer but I'm not sure this solve my question… or maybe it does but I don't get what's really going on with this chain of commands.


Here is a more detailed view of what I'm trying to get (see image below).


As simply as I can say it : I'd like that the red dotted case of the columns "Total frais de bouche" of the right sheet "Frais sur salaires" catches up automatically every money € amount of every line tagged by the cases "Bouche (frais)" in the column "Frais" of the left sheet "JUNE".

I could do it manually by selecting by click but I'm looking for a way to automate it.


Thank you in advance !




Jul 16, 2021 6:40 AM in response to Badunit

Hello Badunit and thank you again.

I think I'm starting to get into the logic of this formula and into the Numbers grammar but I can't succeed to apply it in my document. Very frustrating !

Do you mind if I let you apply this formula in my document by sharing it with you ?

With that I think I can study it and learn how to reproduce it for other needs.

Thank you very much in advance.


[Edited by Moderator]

Create an automatic function in Numbers for Mac

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