• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Relative path for Combine & Load|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Relative path for Combine & Load|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryRelative path for Combine & Loa…
sp_PrintTopic sp_TopicIcon
Relative path for Combine & Load
Avatar
free space

New Member
Members
Level 0
Forum Posts: 1
Member Since:
January 9, 2020
sp_UserOfflineSmall Offline
1
January 9, 2020 - 9:13 am
sp_Permalink sp_Print sp_EditHistory

Hi everyone,

 

I am trying to create a relative path to perform a combine & load for multiple Excel files in a folder. I've been able to create relative paths for a single workbook, but I can't get the functionality the same for a relative path to a folder. Below is what I have: 

 

I have a "GetValue" function;

(rangeName) =>
Excel.CurrentWorkbook(){[Name=rangeName]}[Content]{0}[Column1]

 

Which I use in the query below to import a specific file using a relative path; 

 

let
Source = Excel.Workbook(File.Contents(GetValue("MyExcelFileDataPath"))),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],

 

where "MyExcelFileDataPath" is a named cell which contains the full data path. 

 

But I want to use a similar relative path, instead of the static path that is present in my combine & load query; 

let
Source = Folder.Files("C:\Users\abc123\Reports\Reports Are Located Here"),

 

I've tried using the GetValue function and another named cell with the full data path (something like the below), but it doesn't work; 

let

Source = Folder.Files(GetValue("Data path to report location"))

 

Power Query doesn't seem to recognize the use of GetValue to name the relative path for my folder files. Is there a way to use a relative path specifically for combining & loading a folder? 

 

Thanks!

sp_AnswersTopicSeeAnswer See Answer
Avatar
Mynda Treacy
Admin
Level 10
Forum Posts: 4515
Member Since:
July 16, 2010
sp_UserOfflineSmall Offline
2
January 9, 2020 - 10:16 am
sp_Permalink sp_Print

Hi,

I normally store my file/folder path in a single column Excel table that contains one row. The Table is called "PathTable" and the column is called "FolderPathColumn". The single cell in the PathTable contains a CELL function to automatically return the file path of the query file. 

I save my query file in the folder above the folder containing the data you want to get. This folder is called 'SourceFiles'. I therefore need to use the Text.Combine function to append the folder name 'SourceFiles' to the file path generated by the CELL function, as shown below:

let

    //Get Text or CSV files from a folder

    Path = Excel.CurrentWorkbook(){[Name="PathTable"]}[Content],

    Source = Folder.Files(Text.Combine({Path[FolderPathColumn]{0} ,"SourceFiles"},""))

in

    Source

Mynda

sp_AnswersTopicAnswer
Answers Post
Avatar
J D

New Member
Members
Level 0
Forum Posts: 1
Member Since:
November 4, 2020
sp_UserOfflineSmall Offline
3
November 4, 2020 - 2:14 am
sp_Permalink sp_Print

Thanks Mynda,

I used your "PathTable" method and was able to get it work, however I had to use a search function inside a left function to trim out the file name and sheet name to retrieve only the folder path.

=LEFT(CELL("filename"),SEARCH("[",CELL("filename"))-1)

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Sue Hammond, Malcolm Sawyer
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6355
Posts: 27792

 

Member Stats:
Guest Posters: 49
Members: 32324
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.