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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

Expression.Error: The key didn't match any rows in the table - Exchange Data Import

Hi fellow PBIers,

 

First thing: I know there are several solutions to the Error in the Subject but none of them worked for me.

 

My problem is as follows:

 

  • Built a report & query which igets its data from Exchange Email-Attachments (xlsx-files)
  • Report and query work fine for one day
  • When the new data on the next morning arrives the query "crashes" with the mentioned "key didnt match any rows in the table"
  • It seems to crash because the step in which it opens the attachment of the mail is based on id-key which seems to change for every new mail:
    image.png
    the code from the advanced editor looks as follows:
    #"AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lUAAA=" = #"Filtered Rows1"{[Id="AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lUAAA="]}[Attachments],
        AttachmentContent = #"AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lUAAA="{0}[AttachmentContent],
        #"Imported Excel" = Excel.Workbook(AttachmentContent),
    From my understanding the query looks to import from the mail with that exact id.

    If it would be possible to do this more "dynamic" so that the query really only applies the filter to get the newest mail, extract data from that and import it, then i guess the problem would be solved? Unfortunately i dont know yet how to do this. Has anyone an idea how to solve this?

Thanks a lot in advance and kind regards,

Max

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Okay, so I actually found a solution that works. Gonna leave this here too, in case anyone runs into the same problem:

 

To choose the attachment not based on the Email-ID (like it automatically does) you have to open the "Advanced Editor" in your Power Query and then replace the following code part:

 

 #"AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lTAAA=" = #"Filtered Rows1"{[Id="AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lTAAA="]}[Attachments],
    AttachmentContent = #"AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lTAAA="{0}[AttachmentContent],

with:

 

#"SelectAttachment" = #"Filtered Rows1"{0}[Attachments],
   AttachmentContent = SelectAttachment{0}[AttachmentContent],

then your query will just open the attachment of the Email you filtered for (and ignore the ID)

 

kind regards, max

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Anonymous,

 

You may select Sort Descending and Keep Top Rows under Home tab.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-chuncz-msft thanks for the reply.


i currently perform the following actions before selecting the attachment:

 

  1. sort descending by datetimereceived
  2. keep top rows: 2
  3. filter by name identifier
  4. open attachment

i tried ur solution by only keeping one top row and then opening the attachment, but it still takes the attachment based on the email-id. not quite there yet.

 

 

Anonymous
Not applicable

Okay, so I actually found a solution that works. Gonna leave this here too, in case anyone runs into the same problem:

 

To choose the attachment not based on the Email-ID (like it automatically does) you have to open the "Advanced Editor" in your Power Query and then replace the following code part:

 

 #"AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lTAAA=" = #"Filtered Rows1"{[Id="AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lTAAA="]}[Attachments],
    AttachmentContent = #"AAMkADYzMmZiMmU5LTAzYzMtNGMzYS05MWIwLTg2ZGI2OTE3NGE5ZABGAAAAAACM8/gWvep/QZRIO1D6QBW8BwAjFkhrLDLaT66NTvauBkrRAADloYILAAAjFkhrLDLaT66NTvauBkrRAAG+e/lTAAA="{0}[AttachmentContent],

with:

 

#"SelectAttachment" = #"Filtered Rows1"{0}[Attachments],
   AttachmentContent = SelectAttachment{0}[AttachmentContent],

then your query will just open the attachment of the Email you filtered for (and ignore the ID)

 

kind regards, max

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.