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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Chapin4u
Employee
Employee

Expression Error.: The key didn't match any rows in the table

2017-04-07_15-19-41.png

 

Hi, 

I need help to understand this error message (above image) and how to fix it, thanks 

1 ACCEPTED SOLUTION

 A typical case would be when you connect to an Excel file and then your Query attemps to access a Sheet that does not exist in the Spreadsheet...

View solution in original post

48 REPLIES 48
Anonymous
Not applicable

A user of mine was having this issue. He was connecting to a database though. I gave him Select permission on the database and he was no longer receivinmg this error after refreshing the query.

Devtr
Helper II
Helper II

It's too late. But this might be useful for someone.

When using an Excel spreadsheet and a table connected to PQ, sometimes that table name gets changed unknowingly. Especially when you copy-paste inside the table. Another scenario is the sheet name gets changed too.

I have found this happens.

Thanks.

DDDDD
Frequent Visitor

Not actually an error, odd Power BI behaviour imo.

I had this message for the first time today, on a scheduled report which has been running for months. It uses combine files, but there's been no change to the file location or structure.

 

For me this error message disappeared whilst I was testing the sample file step, I added steps afterwards to expand the table view and the error on the earlier step vanished. I removed the added step and refreshed the report and it was fine. Bizarre.

Hi, 

 

Are you able to share what steps you added? I believe I have a similar issue. The structure of my data hasn't changed and the tab name remains the same. But everytime a new file is added to the folder (Everyday) the refresh breaks due to this error. It seems to be trying to add a blank row to the dataset in each time

rendorHaevyn
New Member

The issue for me was that across 50+ workbooks, the first sheet was not always named the same.  The soultion was to dynamically pick up the first sheet on each workbook, rather than taking the hard coded variable from the sample combine effort.


> Advanced editor on the Transofrm File 

rendorHaevyn_0-1661496686295.png

> Comment out the "data_sheet" line, and add the "FirstSheet" line.  Bingo.

let
    Source = (Parameter1 as binary) => let
        Source = Excel.Workbook(Parameter1, null, true),
        FirstSheet = Table.SelectRows(Source, each [Kind] = "Sheet"){0}[Data],
        // Data_Sheet = Source{[Item="Data",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(FirstSheet, [PromoteAllScalars=true])
    in
        #"Promoted Headers"
in
    Source

 

Pavelfab
New Member

Anonymous
Not applicable

- Click duplicate on source on the right ( Applied step)

- It show a table--> You can see at the Hiddens column--> It's "False"

- Click on "Table" on Data column.

- It's show a msg box (Pic 2) --> Choose continuos 

It's solved

Picture2.png

Picture3.png

Thank you, this was my solution. But I needed to re-create all steps afterwards. In my case it was easy...

Joseph_Dsilva
New Member

I got this error, when I changed the table name in PowerBI Desktop (Fields category) 

George_3029
Frequent Visitor

I had the same error message connecting to a tabular model via visual studio.

 

When I validated the query, "The query statement is valid."

Going into the "Design" view is when I got the error.

 

I fixed it from the "Query" menu, selected refresh query, and it worked.

 

 

Anonymous
Not applicable

I had the same problem today.

 

This is how I fixed it:

Make sure to go under advanced editor on Power BI

matheusvieira_0-1642099778787.png

 

I conected my excel workbook as tables inside Power BI, so in this case you need to make sure that the file location, file name and most important, table name is correct.

______________

let
Source = SharePoint.Files("FILE LOCATION", [ApiVersion = 15]),
#"FILE NAME xlsx_FILE LOCATION" = Source{[Name="FILE NAME.xlsx",#"Folder Path"="FILE LOCATION"]}[Content],
#"Imported Excel Workbook" = Excel.Workbook(#"FILE NAME xlsx_FILE LOCATION"),
Table = #"Imported Excel Workbook"{[Item="TABLE NAME",Kind="Table"]}[Data]
in
Table

_______________

How do you change a table name in excel?

 

Go under Formulas Tab > Name Manager

matheusvieira_1-1642100080298.png

Select the table you want and click edit. This name should be the one you have to insert under Power BI conection above

matheusvieira_2-1642100205682.png

 

Make sure to do this to every imported table on you model

 

 

IvanKo
New Member

I started having this error after populating the file path with daily workbooks where the name of the sheet wasn't the same as my query / Transform Sample File 

(My power query reads from many workbooks wich are the same except for the name of the sheet which is named after each workbook)

The query was attemping to find in all the workbooks the same sheet name as in my data transformation example.

 

I tried to sorted it out by removing the Navigation stept in the query but did not work.

 

How did it work? >In the Transform Sample File, I opened the Advanced Editor and changed the name of the Sheet to zero

 

It was>

 

Source = Excel.Workbook(Parameter1,null,true)

#"03_21_4_20_Sheet"=Source {[Item="03__21_4_20",Kind="Sheet"]}[Data],

 

I changed it to >

 

Source = Excel.Workbook(Parameter1,null,true)

#"03_21_4_20_Sheet"=Source {0}[Data],

 

Regards, 

This one worked for me, thank you!

Anonymous
Not applicable

If you are combining Excel Tables: All tables' names should be the same

If you are combining Excel Sheets: All sheets' names should be the same

 

As simple as that

 

Thanks.

 

John

Anonymous
Not applicable

In my case this error occured when one of the sheets was called differently

russellclaude
Frequent Visitor

I had this error today, and the solution was..... close the database - and all Access databases- that linked to my source file(s). SHAZZAMM! Fixed.

Anonymous
Not applicable

1. First locate the error and find the problematic step,For me the error occurs in "Invoke Custom Function" step, and error is :"An error occurred in the ‘Transform File’ query. Expression.Error: The key didn't match any rows in the table."

 

2. Find the "Transform File" Function 

= (Parameter1) => let
        Source = Excel.Workbook(Parameter1, null, true),
        Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
        #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true])
    in
        #"Promoted Headers"

This code is created according to the excel of the example, prompting other workbooks in our folder, should also be named “sheet1”

 

3.So, just rename all workbooks under the folder sheet's name to "sheet1", this problem can be solved.

Anonymous
Not applicable

Hi,

one more thing that may resolve your problem. Close view in SQL you are trying to pull data from and give Power Bi a try.

 

dan

Anonymous
Not applicable

Thanks, resolved my issue.

heberpower
Frequent Visitor

For me this error was caused by bad login credentials.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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