Report on ContentVersion file types, sizes and attachments by parent record in Salesforce

using Coefficient excel Add-in (500k+ users)

Create detailed ContentVersion reports showing file types and sizes by parent record using custom SOQL queries that native Salesforce reports can't handle.

salesforce to google sheets connector

“Supermetrics is a Bitter Experience! We can pull data from nearly any tool, schedule updates, manipulate data in Sheets, and push data back into our systems.”

5 star rating coeff g2 badge

Salesforce admins can pull ContentVersion file metadata, including file types, sizes and attachment counts, by parent record into Google Sheets using Coefficient’s Salesforce connector and custom SOQL. Native Salesforce reports can’t join ContentVersion, ContentDocument and ContentDocumentLink in a single report. This walkthrough shows how to build that query and keep it refreshing automatically.

The three-object join is the blocker. Salesforce’s standard report builder caps you at two objects per report, which means any analysis touching ContentVersion, ContentDocument and ContentDocumentLink together simply isn’t possible natively. Many Salesforce admins hit this wall regularly. Caitlynn Pérez, reviewing on AppExchange, put it plainly: “Our SCM and financial processes create and delete so many different object records that Salesforce reporting tends to be extremely limited for us when we try tying it all back together. Coefficient has been the biggest help in overcoming this issue for us.”

How to query ContentVersion file types and sizes by parent record

Step 1. Open Coefficient and choose Custom SOQL Query

In Google Sheets or Excel, open Coefficient and select Import from Salesforce. Choose Custom SOQL Query from the import method options, not Report or Object. This is the only import method that lets you write a query spanning ContentVersion, ContentDocument and ContentDocumentLink in a single pull.

Step 2. Build your query across all three objects

Write your query to select FileType and ContentSize from ContentVersion, join through ContentDocument, and filter by LinkedEntityId from ContentDocumentLink to tie each file back to its parent record. Add a WHERE clause on LinkedEntityType to scope results to Accounts, Opportunities, Cases or any other object, whichever records you need to audit first.

Step 3. Import and pivot by file type and parent record

Run the import via Coefficient’s Salesforce connector. Your sheet lands a flat table with each file’s type, size in bytes and the ID of the parent record it belongs to. From there, add a pivot table, group by FileType and sum ContentSize, to see which file types are consuming your storage and on which records.

Step 4. Set a refresh schedule for ongoing storage monitoring

Open the Coefficient scheduler and set a weekly or daily refresh. Your storage table updates automatically each cycle without anyone re-running the query. For active file audits, use daily. For routine storage tracking, weekly is enough.

How to count file attachments per record using ContentDocumentLink

The ContentDocumentLink query covers a related but distinct question: not what the files are, but which records have them. Adapt your SOQL to COUNT ContentDocumentLink rows per LinkedEntityId and group by LinkedEntityType. This gives you an attachment count per Account, Opportunity or Case, data that the standard Salesforce report builder can’t surface because ContentDocumentLink is a junction object outside its two-object join limit.

What you get

Your storage table refreshes on schedule and is always current. You can see which file types are largest, which parent records are accumulating the most files and where your storage is going week over week. Your admin team stops fielding one-off data requests because the numbers are in a shared sheet. For a starting point on how to display this data, see Coefficient’s Salesforce dashboard examples.

Start pulling your ContentVersion storage report today at coefficient.io/get-started.

700,000+ happy users
Get Started Now
Connect any system to Google Sheets in just seconds.
Get Started

Trusted By Over 50,000 Companies