Forum Discussion
Ignore table query with Expression.Error The key didn't match any rows in the table
- 3 years ago
Hi navafolk,
Adapt the 'Transform file' query to Method 1 including the HandleMissing condition and set up an EmpyTable query as well. Here's an illustration
Setting up an if-then-else structure in pre- append queries
Ps. If this helps solve your query please mark this post as Solution, thanks!
- 3 years ago
Thank you @m_dekorte,
Your way works great now. I just try other way round for the EmptyTable
#table(0,{{}})(Create an empty table with M (microsoft.com))
Transform File function in Power Query looks like:
let Source = (Parameter1 as binary) => let Source = Excel.Workbook(Parameter1, null, true), #"Sheet" = try Source{[Item="20230515",Kind="Sheet"]}[Data] otherwise 1, IsMissing = if Sheet=1 then #table(0,{{}}) else let #"Removed Top Rows" = Table.Skip(#"Sheet",1), #"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]) in #"Promoted Headers" in IsMissing in Sourcethen remove null row in Query1 and they are all beautiful now.
Hi m_dekorte,
It showed error at EmptyTable.
Expression.Error: The name 'EmptyTable' wasn't recognized. Make sure it's spelled correctly.Should it be pre-defined somewhere? Thank you.
Thank you @m_dekorte,
Your way works great now. I just try other way round for the EmptyTable
#table(0,{{}})(Create an empty table with M (microsoft.com))
Transform File function in Power Query looks like:
let
Source = (Parameter1 as binary) => let
Source = Excel.Workbook(Parameter1, null, true),
#"Sheet" = try Source{[Item="20230515",Kind="Sheet"]}[Data] otherwise 1,
IsMissing = if Sheet=1
then #table(0,{{}})
else let
#"Removed Top Rows" = Table.Skip(#"Sheet",1),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true])
in
#"Promoted Headers"
in IsMissing
in
Sourcethen remove null row in Query1 and they are all beautiful now.