+ Reply to Thread
Results 1 to 5 of 5

Append multiple DBF files in PowerQuery with with a changing path

Hybrid View

  1. #1
    Registered User
    Join Date
    05-27-2019
    Location
    Sofia
    MS-Off Ver
    Professional Plus 2016
    Posts
    3

    Append multiple DBF files in PowerQuery with with a changing path

    Hello, I need to Append multiple DBF files, but every time I have difference path (folder)
    I have code :


    fnGetDBF

    (MyPath, MyFile) =>
    let
        Source = Odbc.DataSource("dsn=dBASE Files", [HierarchicalNavigation=true]),
        Database = Source{[Name=MyPath,Kind="Database"]}[Data],
        Table = Database{[Name=MyFile,Kind="Table"]}[Data]
    //  Your transformations here
    
    in
        Table

    Use this function to combine all the dbf tables in a folder:

    CombineDBFTables

    let
        Source = Folder.Files("C:\YourPath\DBF"),
        #"Filtered Rows" = Table.SelectRows(Source, each [Extension] = ".dbf"),
        #"Added MyPath" = Table.AddColumn(#"Filtered Rows", "MyPath", each Text.TrimEnd([Folder Path],"\")),
        #"Added MyFile" = Table.AddColumn(#"Added MyPath", "MyFile", each Text.Replace([Name],[Extension],"")),
        #"Get Tables" = Table.AddColumn(#"Added MyFile", "fnGetDBF", each fnGetDBF([MyPath], [MyFile])),
        #"Combine Tables" = Table.Combine(#"Get Tables"[fnGetDBF])
    in
        #"Combine Tables"

    BUT when I try to change the Path in red with fnGetDBF the code didn't work.

    Can you someone help me, please.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,824

    Re: Append multiple DBF files in PowerQuery with with a changing path

    Where have you defined MyPath and MyFile?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    05-27-2019
    Location
    Sofia
    MS-Off Ver
    Professional Plus 2016
    Posts
    3

    Re: Append multiple DBF files in PowerQuery with with a changing path

    I tried to export them from the excel source, with simple excel function like
    =LEFT(CELL("filename"),FIND("[",CELL("filename"))-1)

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,824

    Re: Append multiple DBF files in PowerQuery with with a changing path

    I think you need to attach a workbook.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  5. #5
    Registered User
    Join Date
    05-27-2019
    Location
    Sofia
    MS-Off Ver
    Professional Plus 2016
    Posts
    3

    Re: Append multiple DBF files in PowerQuery with with a changing path

    This is my Excel file. It's work with specific file path.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Append multiple DBF files in PowerQuery
    By wrybel in forum Excel General
    Replies: 18
    Last Post: 05-24-2020, 11:55 PM
  2. Replies: 0
    Last Post: 05-18-2017, 06:58 PM
  3. Append Multiple XML Files to a table in Excel
    By pritchard.ev in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-18-2016, 07:28 AM
  4. Append data from multiple excel files with respective file name
    By vijay20cbe in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-17-2014, 12:07 PM
  5. [SOLVED] Append Data to Multiple Files based upon Criteria
    By Topo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-28-2012, 02:14 PM
  6. Macro to append multiple xls file in single workbook from specified path
    By koksamsun in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-18-2010, 05:29 AM
  7. Append multiple csv files into master file?
    By Delta223 in forum Excel General
    Replies: 28
    Last Post: 01-30-2010, 02:49 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1