Forum Discussion

dozer_1985's avatar
dozer_1985
Regular Visitor
3 years ago
Solved

Combine and transform issue - Expression.Error: The key didn't match any rows in the table.

Here is the code that it's using to Transform in bold   Transform file (2) step "= (Parameter2) => let Source = Excel.Workbook(Parameter2, null, true), #"Sheet_Suffix" = Source{[Item="SheetSuffi...
  • jbwtp's avatar
    3 years ago

    Hi dozer_1985,

     

    The reason why it fails with the wildcards is because PQ does not understand the wildcards (not in this case). The Source{0} fails where the required datasheet is not always your first tab (it is internal indexing, nit necessarily reflecting the order of tabs in the book).

    There are few ways to resolve it:

    1. Just filter the Source to select only items containing Sheet_Suffix (kind of forcing the wildcard): Text.Contains ([Item], "Sheet_Suffix"). Then you should be able (I presume) to use #"Sheet_Suffix" = Source{0}[Data].

    2. Alternatively (and in some other cases maybe more reliably) something like: #"Sheet_Suffix" = Source{[Item=Parameter2 & "_Sheet_Suffix",Kind="Sheet"]}[Data] or whatever is needed to dynamically set the sheet name from your filename and the suffix.

     

    Kind regards,

    John