Relative Folder Path: Power Query Guide

Поділитися
Вставка
  • Опубліковано 4 січ 2025

КОМЕНТАРІ • 10

  • @abbadq
    @abbadq 3 місяці тому +2

    👍 key point to knowledge.

  • @FsoOmar
    @FsoOmar 3 місяці тому +1

    Great Tip! Thank you.

    • @howtolearnexcel
      @howtolearnexcel  3 місяці тому +1

      Yeah, saves some time. I wish it were added as an native option in PQ. Thank you!

  • @omarnader776
    @omarnader776 4 місяці тому +1

    Great

  • @constantsignals4474
    @constantsignals4474 2 місяці тому +1

    works perfect for local files/folders. but does not work for me when moving the folder to onedrive/sharepoint. any suggestions?

    • @howtolearnexcel
      @howtolearnexcel  2 місяці тому +1

      Interesting question. I need to research it a bit.
      By the way, do you mean a personal OneDrive or OneDrive for Business?
      As for SharePoint, you should check this video:
      ua-cam.com/video/mgVnk4R79ac/v-deo.html
      P.S. I'll try to find the solution and answer a bit later.

    • @constantsignals4474
      @constantsignals4474 2 місяці тому +1

      @@howtolearnexcel thanks for linking the sharepoint video. I was talking bout OneDrive for business. In our company it often happens that people do some analysis local and then want to share it with onedrive or sharepoint. the static paths always break

    • @howtolearnexcel
      @howtolearnexcel  2 місяці тому

      I can confirm that this is possible. But it is a bit tricky.
      For example, to connect to your own Business OneDrive directory, you need to get this part of the address:
      comapanyname-my.sharepoint.com/personal/login/ (and delete everything else).
      If your consolidation file is placed there too, you can use the formula to grab the part before the 5th slash. Like this:
      =LEFT(CELL("filename",A1), FIND("#", SUBSTITUTE(CELL("filename",A1), "/","#", 5)))
      Then place it in the "Table1" - "Path" column.
      The PQ code will be following:
      let
      Source = SharePoint.Contents(Excel.CurrentWorkbook(){[Name="Table1"]}[Content]{0}[Path], [ApiVersion = 15]),
      Documents = Джерело{[Name="Documents"]}[Content]{[Name="SubfolderName"]}[Content]
      in
      Documents
      The first line grabs the relative path. The second is where you define the subfolder (as many levels as needed).
      You can use SharePoint.Contents or SharePoint.Files function depending on what you need.
      If you want, you can modify your code to work with local files and the SP\OneDrive. To do this, you can simply use:
      if Text.StartsWith(Excel.CurrentWorkbook(){[Name="Table1"]}[Content]{0}[Path],"http") then (code above) else (code from my video).
      The same works with other "common" SP folders as well if you have access.
      P.S. Here is one more Wyn's video on this topic with more in depth explanation:
      ua-cam.com/video/-XE7HEZbQiY/v-deo.html