Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
I'm using Microsoft Exchange to insert attachments from emails that come monthly. Within the attachment, there are multiple tabs. I need to filter to the specific tab I want to be combined each month. The tabs are not titled the exact same way (ex. January Usage Report, February Usage Report). Is the only way to combine files automatically to have the tabs named identically each month?
Hi @Soc3 ,
You could refer to the blog to know:
How to provide sample data in the Power BI Forum - Microsoft Power BI Community
How to Get Your Question Answered Quickly - Microsoft Power BI Community
Best Regards,
Eyelyn Qin
Not necessarily, can you provide two sample files that differ as you've described. Remove/change any sensitive data.
This will make it easier for us to offer a solution.
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Thanks for your quick reply! I don't see a way to attach the files on the forum, can you provide your email?
The attaching is restricted unfortunately.
Just share using Google Drive, Drop Box etc.
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Hi @Soc3,
Have a look at the attached PBIX file.
First thing, change the pFileDirectory parameter to wherever you have the files stored locally. (This can be altered later obviously if they aren't going to be local files)
I made some assumptions.
This should be a good starting point, let me know if you have questions.
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Hi @KNP ,
Your assumptions were correct and the output looks great! Is this still using Microsoft Exchange? How do I provide a file path to my inbox?
Hi @Soc3,
This isn't using Microsoft Exchange as I had no way to build the example that way.
To be honest, the performance I've seen when connecting to exchange would put me off using it. Typically, if I have files coming in via email, I'll use Power Automate to extract them and put them on a SharePoint site, then connect to them from there.
If you need to use exchange, create a new step that filters to the files you need and make sure you change the column name of 'AttachmentContent' to 'Content' then just change the reference in the 'UsageReports' query to point at your exchange query.
^not sure if that description will make sense to you.
New query, something like this...
(you'll need to add other filtering as required)
let
Source = Exchange.Contents("youremail@yourdomain.com"),
Mail1 = Source{[Name = "Mail"]}[Data],
#"Filtered Rows" = Table.SelectRows(Mail1, each ([HasAttachments] = true)),
#"Expanded Attachments" = Table.ExpandTableColumn(
#"Filtered Rows",
"Attachments",
{"Name", "Extension", "AttachmentContent"},
{"Name", "Extension", "AttachmentContent"}
),
#"Renamed Columns" = Table.RenameColumns(
#"Expanded Attachments",
{{"AttachmentContent", "Content"}}
)
in
#"Renamed Columns"
For the sake of example, we'll say you called this new query 'Mail'.
Now change the 'UsageReports' query to reference 'Mail' instead of 'Files'...
(e.g. Source = Files to Source = Mail)
let
Source = Mail,
ROC1 = Table.SelectColumns(Source, {"Content"}),
InvokefProcessUsageReportFiles = Table.AddColumn(
ROC1,
"fProcessUsageReportFiles",
each fProcessUsageReportFiles([Content], "usage report")
),
ROC2 = Table.SelectColumns(InvokefProcessUsageReportFiles, {"fProcessUsageReportFiles"}),
ExpandColumns = Table.ExpandTableColumn(
ROC2,
"fProcessUsageReportFiles",
{
"Contact Name",
"Contact: Email",
"Case Origin",
"Opened Date",
"Case Number",
"Disposition",
"Topic",
"Case Type",
"Subject"
},
{
"Contact Name",
"Contact: Email",
"Case Origin",
"Opened Date",
"Case Number",
"Disposition",
"Topic",
"Case Type",
"Subject"
}
)
in
ExpandColumns
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
Hi again @KNP , thank you so much for your help! Last question, how do I switch the data source for pFileDirectory to point to a Sharepoint folder? I tried replacing the file path with the link and get this error.
The original query...
let
Source = Folder.Files(pFileDirectory),
FilterRows = Table.SelectRows(Source, each Text.Contains(Text.Lower([Name]), "usage report"))
in
FilterRows
You'd need to change the query to use SharePoint.Files not Folder.Files.
There may be some other minor tweaks required but that'll give you a start.
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |