Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi people,
MIght someone give me hint to find some reference
Folder.Files(path as text, optional options as nullable record) as table
Folder.Contents(path as text, optional options as nullable record) as table
Both them shows parameter options, but I don't find any reference for those options?
What options I can use there and is there some option to include subfolders into response table
THanks in advance
Henn
PS! Recomentation for docs-writers - include that kind of info into docs
Solved! Go to Solution.
Hi @HennSarv ,
About the optional paremeter in Folder.Files() function, the official document has not explained it in details.
Based on my test, this parameter is about restricting power bi to get data when the file in the folder is opened / accessed.
For example, I have created two queries both connecting to the same folder, one of the parameter is set as true, another is set as false.
When I do not open any files in the folder, I can get the data from both queries. Both of them can import data into power bi:
When I open the file in the folder and refresh the query in power bi, the query which parameter is set as true will get IO errors like below while the false parameter can get data normally:
In addition, if the parameter is null by default, the result is the same as when the parameter is false.
Hopes it could help you to understand this optional parameter.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-yingjl - thanks for explanation. It helps lot
I looked actually for recurse-like option and I craeted now some sample PowerQuery function - might be interesting. Nice to have this functionality 'ready-from-box'
DirContent = // this is function-query name
// rest is function-query body
(path as text) as table =>
let
Source = Folder.Contents(path),
Folders = Table.SelectRows(Source, each ([Attributes][Directory] = true)),
Step1 = Table.SelectColumns(Folders,{"Name", "Folder Path"}),
Step2 = Table.AddColumn(Step1, "DirContent", each DirContent([Folder Path]& [Name])),
Step3 = Table.RemoveColumns(Step2,{"Folder Path", "Name"}),
Expanded = Table.ExpandTableColumn(Step3, "DirContent", {"Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}, {"Content", "Name", "Extension", "Date accessed", "Date modified", "Date created", "Attributes", "Folder Path"}),
Files = Table.SelectRows(Source, each ([Attributes][Directory] = false)),
Result = Table.Combine({Files,Expanded})
in
Result
I think Step2 may need to look like this:
Step2 = Table.AddColumn(Step1, "DirContent", each @DirContent([Folder Path]& [Name])),
Without @ sign self-reference may not work.
Kind regards,
JB
Hi @HennSarv ,
About the optional paremeter in Folder.Files() function, the official document has not explained it in details.
Based on my test, this parameter is about restricting power bi to get data when the file in the folder is opened / accessed.
For example, I have created two queries both connecting to the same folder, one of the parameter is set as true, another is set as false.
When I do not open any files in the folder, I can get the data from both queries. Both of them can import data into power bi:
When I open the file in the folder and refresh the query in power bi, the query which parameter is set as true will get IO errors like below while the false parameter can get data normally:
In addition, if the parameter is null by default, the result is the same as when the parameter is false.
Hopes it could help you to understand this optional parameter.
Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @HennSarv ,
This is @mahoneypat 's post about 8 months ago on the same topic explaining how to explore function signatures yourself: https://community.powerbi.com/t5/Power-Query/Optional-options-as-nullable-record/m-p/1060180#M35573
In the essence, in both cases, the optional parameter directs if the access time needs to be preserved (i.e. "ignored" the access by PBI).
Kind regards,
JB
Folder.Files includes subfolder content automatically (the other does not). You can then filter further with the Folder Path column if needed.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.