Dear DNA Team,
I am seeking your advice.
I am trying to connect the generic mailbox to the Power BI. As per the below m-code, I am only interested in the data 2020 onwards plus folders that = Inbox, =Sent Items, and any folder that contains Archive.
When I press save and load 1.5h ago from this moment, the data is still loading.
Am right to say that power BI is going through every individual item in the maiblox and then applies the m code to return the emails that meets the criteria? Would it be wise to move emails from 2020 onwards to one folder?
Could you please advise what could I do to speed up the loading?
let
Source = Exchange.Contents("xxxxxx@company.com"),
Mail1 = Source{[Name="Mail"]}[Data],
#"Removed Other Columns" = Table.SelectColumns(Mail1,{"Folder Path", "Subject", "Sender", "DateTimeReceived"}),
#"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Email", each Record.Field([Sender],"Address")),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom",{{"DateTimeReceived", type date}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"Sender"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Columns", each [DateTimeReceived] > #date(2019, 12, 31)),
#"Added Conditional Column" = Table.AddColumn(#"Filtered Rows", "Folder", each if [Folder Path] = "\Inbox\" then "Inbox" else if [Folder Path] = "\Sent Items\" then "Sent" else if Text.Contains([Folder Path], "\Archive\") then "Solved" else 1),
#"Filtered Rows1" = Table.SelectRows(#"Added Conditional Column", each [Folder] <> "1"),
#"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows1",{"Folder", "Folder Path", "Subject", "DateTimeReceived", "Email"}),
#"Removed Columns1" = Table.RemoveColumns(#"Reordered Columns",{"Folder Path"})
in
#"Removed Columns1"
Thank you,
Mateusz