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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors