Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ansa_naz
Continued Contributor
Continued Contributor

Query editor question - count number of valid email attachments

Hi all

 

Is there any way for me to count the number of valid attachments within an email in Query Editor?  To do that, I need to ignore the header logo, footer logo, other random bits of garbage that show up as attachments on the email. So I need to count the number of attachments where the 'ContentType' field starts with 'Application'

 

I have aggregated the Attachments column by count of Attachment Name, but I want to add in a condition where the COUNT will only include attachments where the 'ContentType' of the attachment begins with 'Application' - how can I do this please?

 

My query is currently like this:

 

let
    Source = Exchange.Contents("XXX@XXX.co.uk"),
    Mail1 = Source{[Name="Mail"]}[Data],
    #"Filtered Rows" = Table.SelectRows(Mail1, each ([Folder Path] = "\Inbox\Purchase Ledger\Invoices\In Query\" or [Folder Path] = "\Inbox\Purchase Ledger\Invoices\New\" or [Folder Path] = "\Inbox\Purchase Ledger\Statements\New\")),
    #"Aggregated Attachments" = Table.AggregateTableColumn(#"Filtered Rows", "Attachments", {{"Name", List.NonNullCount, "Count (Not Blank) of Attachments.Name"}})
in
    #"Aggregated Attachments"

 

Many thanks for all help

1 REPLY 1
ansa_naz
Continued Contributor
Continued Contributor

Found a different way to do this

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.