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
rtrejo
Regular Visitor

Source{[Name="Mail"]}[Data] Query optimization

Hello, I have a query to connect via the exchange as I need to count the email addresses in a specific folder (Inbox) for 6 shared mailboxes.

 

I'm using a custom function: 

 

let
Source = (Account as text) as table=>

let
Source = Exchange.Contents(""&Account&""),
Mail1 = Source{[Name="Mail"]}[Data]
in
Mail1
in
Source

 

I'm able to get the information, however, the information takes about 10 minutes to load as it validates all the folders. 

 

Is there any way to optimize this in order to quickly load the information just for the Inbox folder? 

 

Here is the table information: 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSs7PzU3MS0l1KC5JzSkoytcDCijF6iAkUlJLEjNzMKSLC/Lzc1JSi2HKikuLEzEUFeViFdPDYSZICsOYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Allacount = _t]),
#"Type modifié" = Table.TransformColumnTypes(Source,{{"Allacount", type text}}),
#"Fonction personnalisée appelée" = Table.AddColumn(#"Type modifié", "Email Traffic", each #"Email Traffic"([Allacount])),
#"Email Traffic développé" = Table.ExpandTableColumn(#"Fonction personnalisée appelée", "Email Traffic", {"Folder Path", "Sender", "DisplayTo", "DisplayCc", "DateTimeReceived", "HasAttachments", "Attributes"}, {"Email Traffic.Folder Path", "Email Traffic.Sender", "Email Traffic.DisplayTo", "Email Traffic.DisplayCc", "Email Traffic.DateTimeReceived", "Email Traffic.HasAttachments", "Email Traffic.Attributes"}),
#"Expanded Email Traffic.Attributes" = Table.ExpandRecordColumn(#"Email Traffic développé", "Email Traffic.Attributes", {"LastModifiedName"}, {"Email Traffic.Attributes.LastModifiedName"}),
#"Lignes filtrées" = Table.SelectRows(#"Expanded Email Traffic.Attributes", each ([Email Traffic.Folder Path] = "\Boîte de réception\" or [Email Traffic.Folder Path] = "\Éléments envoyés\")),
#"Colonnes supprimées" = Table.RemoveColumns(#"Lignes filtrées",{"Email Traffic.Sender"}),
#"Type modifié1" = Table.TransformColumnTypes(#"Colonnes supprimées",{{"Email Traffic.DateTimeReceived", type date}}),
#"Semaine de l'année insérée" = Table.AddColumn(#"Type modifié1", "Week number (year)", each Date.WeekOfYear([Email Traffic.DateTimeReceived]), Int64.Type),
#"Filtered Rows" = Table.SelectRows(#"Semaine de l'année insérée", each ([Email Traffic.Folder Path] = "\Boîte de réception\"))
in
#"Filtered Rows"

 

 

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @rtrejo ,

Before using the source table to transform data in Power Query directly, you can consider to select necessary rows in advance to reduce the table size to import into Power Query.

 

In addition, if the source table would be used frenquently in a new query, you can try to Table.buffer() to buffer the source table. Please refer this blog which introduces it in details:

Nested functions and Table.Buffer() 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

1 REPLY 1
v-yingjl
Community Support
Community Support

Hi @rtrejo ,

Before using the source table to transform data in Power Query directly, you can consider to select necessary rows in advance to reduce the table size to import into Power Query.

 

In addition, if the source table would be used frenquently in a new query, you can try to Table.buffer() to buffer the source table. Please refer this blog which introduces it in details:

Nested functions and Table.Buffer() 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors