Forum Discussion

nok's avatar
nok
Icon for Advocate II rankAdvocate II
9 months ago
Solved

Trim the spreadsheet name in "transform file" code

Hi! I have a PowerQuery "transform file" code which is used for append the data from all spreadsheets named "BAN" within the excel files stored in the same folder on my SharePoint. This is my code: ...
  • rohit1991's avatar
    9 months ago

    Hii nok 

     

    You can fix this by trimming the sheet name before filtering it. Excel.Workbook returns a table with a [Name] column, so instead of matching "BAN" exactly, match the trimmed name. Just change your step to:

    BAN_Sheet = Source{[Item = Text.Trim("BAN"), Kind = "Sheet"]}[Data]

    This ensures that "BAN", "BAN " or " BAN" all resolve to the same sheet, and your append process won’t break due to extra spaces.