Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I am trying to represent a folder and file structure in a report. I want to be able to expand and minimise the folders. Is this possible within PowerBI? I have been playing around with Matrix Visual and Hierarchies and can't get it right.
The data is already in a SQL database and I can export to Excel. There are two tables, folders and files.
Folder table: id_object, foldername, id_parent
Files table: id_object, filename, id_parent
I idealy want to display it in a matrix looking like this (ignore the size / type - don't need those)
Any help would be apprechiated. Thanks
Thank you for reaching out to the Microsoft Fabric Forum Community.
Please try below, For your reference, I’m attaching the .pbix file
Excellent question. Yes, it’s absolutely possible to represent a Windows-style folder hierarchy in Power BI using the Matrix visual with a parent-child hierarchy model.
Power BI doesn't directly support native "expand/collapse" like Windows Explorer, but with the correct data modeling, the Matrix visual behaves similarly, letting you expand folders into files.
Folders Table
| id_object | foldername | id_parent |
|------------|------------|-----------|
Files Table
| id_object | filename | id_parent |
Create a single table with both folders and files. Example using Power Query (Transform Data):
SELECT id_object, foldername AS Name, id_parent, 'Folder' AS Type FROM Folders
UNION ALL
SELECT id_object, filename AS Name, id_parent, 'File' AS Type FROM Files
Or merge them in Power BI using Append Queries.
Power BI doesn't automatically build hierarchies from parent-child structures. You have to create a calculated column to build the hierarchy path.
In Power BI Model view, create a column:
Create levels for each depth:
Add as many levels as the deepest part of your hierarchy.
Insert a Matrix visual.
Add Level1, Level2, Level3, etc. into the Rows field in order.
Add Type (optional) or file counts, sizes (if available) into Values.
Now folders and files will be shown like:
Root
└── Folder1
├── Subfolder1
│ └── FileA
└── Subfolder2
└── FileB
@jimmytwoburgers - there was a missing disclaimer from @DanielaOliveira's answer. Here, I'll add it...
"This answer was pasted directly from ChatGPT. ChatGPT can make mistakes. Check important info."
Have I solved your problem? Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;). |
If you found this post helpful, please give Kudos. It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen. If you find my signature vaguely amusing, please give Kudos. | Proud to be a Super User! |
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
79 | |
79 | |
58 | |
36 | |
33 |
User | Count |
---|---|
93 | |
59 | |
59 | |
49 | |
41 |