Forum Discussion

Alvarom1's avatar
Alvarom1
Helper I
6 years ago
Solved

Add column with folder name

Hi,

I am getting data from Sharepoint where I have excel files in different folders. 

I need to add a column to my date that shows the name of the folder where the file source is.

Example:

Folder "sharepoint/folder 1/: 

  • File A
  • File B
  • File C

Folder "sharepoint/folder 2/:

  • File A
  • File B
  • File C

 

What I need is, on the combined table that I get on Power BI, add a column, for each line, with the reference of folder and file of origin:

  • 1/A
  • 1/B
  • 1/C
  • 2/A
  • 2/B
  • .......

 

Can you help me?

 

Thanks 

 

Alvaro

 

 

  • I assume you are opening the files via the Combine operation and your query steps look something like this, where the items in the red square were created by Power Query automatically by the Combine operation:

     

    Go to the "Removed Other Columns1" step, and click the little gear icon. Check the "Folder Path" box and hit OK.

    Go to the end of your query steps and you'll have a new folder path column where those files are located. You can then use Text.Start, Text.Middle, Text.End, or whatever to create whatever text you want to combine with the folders.

9 Replies

  • edhans's avatar
    edhans
    Community Champion

    I assume you are opening the files via the Combine operation and your query steps look something like this, where the items in the red square were created by Power Query automatically by the Combine operation:

     

    Go to the "Removed Other Columns1" step, and click the little gear icon. Check the "Folder Path" box and hit OK.

    Go to the end of your query steps and you'll have a new folder path column where those files are located. You can then use Text.Start, Text.Middle, Text.End, or whatever to create whatever text you want to combine with the folders.

    • parry2k's avatar
      parry2k
      Super User

      Alvarom1 as edhans you go to step where you connect to sharepoint folder and make sure you can see folder path column in there and then check if you removed this column in any of the following step, if yes, don't remove this column so that is is part of your table , similar for filename and after that you can use any  Text functions to concatenate  File Name and Folder Path

       

      Hope this help. If something is not clear, provide more details with example what is missing or what need to be done.

    • Alvarom1's avatar
      Alvarom1
      Helper I

      That's it!

      That is wath I need and I did not know

      Thanks a lot

      Alvaro

      • edhans's avatar
        edhans
        Community Champion

        Great. That folder path column is available when you start, but the Combine operation automatically hides it and most other columns once it opens the actual files. I go back in and add them back for similar reasons all of the time. 👍

  • Alvarom1 when you connect to sharepoint folder it has a column called  Folder Path and you can use that to concatenate with file name

     

    Would appreciate Kudos 🙂 if my solution helped.

     

    • Alvarom1's avatar
      Alvarom1
      Helper I

      HI thanks,

      When I combined all the excel files with power bi I get a long list with all the lines from those excel. On that one, I do not have the path folder. What I need is , on that combined table, be able to add part of the text of the folder with each line(file) is coming from.

      Makes sense?

      Thanks

      Alvaro