Help

How to count number of individual attachments/files within a record?

Topic Labels: Formulas
Solved
Jump to Solution
6342 7
cancel
Showing results for 
Search instead for 
Did you mean: 
Kyle_Jones
5 - Automation Enthusiast
5 - Automation Enthusiast

So I have a single Attachments field in a table that allows for multiple individual files to be attached to a record. I want to create another field that counts the number of files that have been uploaded/attached to that record. I then want to them pull this number into the primary field of the table to provide a quick way to see how many files have been attached to the record (e.g., 5 videos, 11 screenshots).

However, the built-in ‘count’ formulas seem to be only counting the occurrence of an attachment for the record, not the number of individual files within the record; so as a result, it is only showing things as having 1 or 0 attachments, even though there are multiple individual files that have been attached to that record within the Attachments field. I came across an old thread about counting attachments (for some reason it’s preventing me from including the link here) but it seems outdated given the formulas now available, plus I could not get the formula to work at all.

Any ideas on how (or if) I can make it count the number of individual files that have been uploaded/attached to a single record?

Thanks!

Edit: Forgot to mention I only have a very basic knowledge of formulas, so please bear with me :winking_face:

1 Solution

Accepted Solutions

Just test to make sure the Attachments field isn’t empty first.

IF(
Attachments=BLANK(), 0,
LEN(Test)-LEN(SUBSTITUTE(Test,",",""))+1
)

NOTE: I’m rewriting here the formula in the Test field in Victoria’s example, in which the Test field correctly counting attachments unless there aren’t any. The formula above fixes that.

William

See Solution in Thread

7 Replies 7
VictoriaPlummer
7 - App Architect
7 - App Architect

This is a cool concept and fairly straightforward. Each attachment is separated by a comma. So, you can count the number of commas in the Attachment field to see how many attachments there are. See this example. Hope it helps!

Kyle_Jones
5 - Automation Enthusiast
5 - Automation Enthusiast

Wow this is perfect, thank you @VictoriaPlummer! I was able to copy the base you provided and adapt the formulas to my fields.

Kyle_Jones
5 - Automation Enthusiast
5 - Automation Enthusiast

Oh shoot @VictoriaPlummer I spoke too soon. Looks like it is still counting records with no attachments as having 1 attachment. It’s also doubling the count in some instances; for example, a record with 5 videos attached is being counted as having 10 attachments. Any ideas?

Edit: The second issue with things being counted twice was due to commas in the file name. Still have the first one though with zero attachments being counted as 1.

Oh yeah that will happen in the way that the formula is structured. You can throw an IF statement around the existing formula to test for IF an attachment exists, then run the formula, otherwise return 0

Just test to make sure the Attachments field isn’t empty first.

IF(
Attachments=BLANK(), 0,
LEN(Test)-LEN(SUBSTITUTE(Test,",",""))+1
)

NOTE: I’m rewriting here the formula in the Test field in Victoria’s example, in which the Test field correctly counting attachments unless there aren’t any. The formula above fixes that.

William

Kyle_Jones
5 - Automation Enthusiast
5 - Automation Enthusiast

@VictoriaPlummer and @WilliamPorterTech yall rock! Thank you so much for the help, got it all working in my base.

Hello William,

Thank you for sharing the formula to count the number of attachments. I assume the "Test" field is a formula field referencing the attachments field, which is named "Attachments" in this context. I applied it to my Airtable base and found that, in some cases, the formula field shows a higher number of attached files than the actual number in the attachment field. For example, a record in my database contains only 3 files, but the formula field indicates 6 files instead of 3. Another case is that a record in the same base of mine stores only one attached file, but the same formula field indicates 2 files.

In my context, the attachment field is named "Supporting Documents." I created an additional field called "Test," with the formula {Supporting Documents} referencing the "Supporting Documents" field. The formula I adapted based on your original suggestion is:

IF({Supporting Documents}=BLANK(), 0, LEN(Test)-LEN(SUBSTITUTE(Test, ",", ""))+1)

Could you please help me fix the issues mentioned?

Thank you