Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
HennSarv
Helper I
Helper I

Follder.Content and Folder.Files option

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

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

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.

true.pngfalse.png

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:

t1.pngf1.png

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:

t2.pngf2.png

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.

 

View solution in original post

5 REPLIES 5
HennSarv
Helper I
Helper I

@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



Anonymous
Not applicable

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

 

v-yingjl
Community Support
Community Support

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.

true.pngfalse.png

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:

t1.pngf1.png

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:

t2.pngf2.png

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.

 

Anonymous
Not applicable

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

 

mahoneypat
Employee
Employee

Folder.Files includes subfolder content automatically (the other does not).  You can then filter further with the Folder Path column if needed.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors