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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

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

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors