Forum Discussion
Folder as parameter
Anonymous - So, are you using a Folder query or are you grabbing them all individually? When you use a Folder query, there is a step where the name of the file is included. I think it gets selected out but you could modify the queries to keep it. Not sure if this is what you are going for or something else. It's not super clear.
Thanks Greg_Deckler., sorry if i am not clear
I am trying to read data from a folder as Data source. Assume folder contains 10 files If i read the latest modified file (Top 1 row) this works perfect.
My question was if i need to show the user a list of file names in this folder (10 names), so they can choose which file they want to analyse?
I hope this will be clear? Is there any clean way to do the user input on folder?
Cheers
- amitchandak5 years agoSuper User
Anonymous , Not sure I got it . but you have Folder.Files, that will return you table of files
https://docs.microsoft.com/en-us/powerquery-m/folder-files
also refer : https://radacad.com/power-bi-get-data-from-multiple-files-in-a-folder-on-onedrive-for-business-no-gateway-needed
- Greg_Deckler5 years agoCommunity Champion
ImkeF edhans , how do you preserve the Source.Name field in a Folder query so that it shows up as a column in the final table? Thanks.
- edhans5 years agoCommunity Champion
Anonymous - to preserve any columns after you've done a combine operation, go back to the automatically generated Remove Other Columns1 step, hit the gear icon, and check what you want to keep. I think the August 2020 version of Power BI Desktop does this automatically for you (I just tested) but I know this has not always been the case, and it may depend on the types of files (text, Excel) and where you are combining from (OneDrive, local folder, SharePoint Library, DataLake, etc.)
You can see that Folder Path is there for selection as well if you want it.
- Greg_Deckler5 years agoCommunity Champion
edhans - Thanks, for some reason I could not track that down!! Anonymous does this get you where you need to be?