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

Join 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.

Reply
jimmytwoburgers
New Member

Is it possible to represent a windows file and folder structure in a report?

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)

 

jimmytwoburgers_0-1750698255561.png

Any help would be apprechiated.  Thanks

 

3 REPLIES 3
v-priyankata
Community Support
Community Support

Hi @jimmytwoburgers 

Thank you for reaching out to the Microsoft Fabric Forum Community.

Please try below, For your reference, I’m attaching the .pbix file

  • Add a column to distinguish between folders and files (e.g.,type="Folder" or "File")
  • Combine both tables into a single table using Union in Power Query.
  • Add Matrix to distinguish b/w Files and folders


    If this information is helpful, please “Accept as solution”  to assist other community members in resolving similar issues more efficiently.
    Thank you.

DanielaOliveira
New Member

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.


🔧 How to Build Folder/File Hierarchy in Power BI (Step-by-step)

Data Model Structure:

  • Folders Table
    | id_object | foldername | id_parent |
    |------------|------------|-----------|

  • Files Table
    | id_object | filename | id_parent |


🔗 Step 1: Combine Folder and File into One Table

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.


🏗Step 2: Create Parent-Child Hierarchy

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:

 

DAX:
Path = PATH(Combined[id_object], Combined[id_parent])
 

 

🔎 Step 3: Break into Levels

Create levels for each depth:

 

DAX
CopyEdit
Level1 = PATHITEM(Combined[Path], 1, TEXT) Level2 = PATHITEM(Combined[Path], 2, TEXT) Level3 = PATHITEM(Combined[Path], 3, TEXT)
 

Add as many levels as the deepest part of your hierarchy.


📊 Step 4: Build Matrix

  • 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 ;).
chrome-9xf-Zagzel-B

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.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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