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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply

I have a report displaying file size against users - how can I accurately display this?

I have a report which displays files and folders and their file size. For example,

 

PathSizeOwner
C:\User\Tom12.5GBTom
C:\Users\Tom\Documents3GBTom
C:\Users\Tom\Pictures2GBTom
C:\Users\Tom\Music1GBTom
C:\Generic11.5GBTom

 

If I 'SUM' all the values I get a value much larger than intended and therefore incorrect. Documents, Pictures, Music would ultimately make up the size for C:\Users\Tom. But of course, the 'SUM' function would add all of it. If I do 'MAX' it will only take into account the C:\Users\Tom value.

 

Is there a way to only get the top-level folders and their size?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @dinosainsburys ,

 

Thanks for the reply from rajendraongole1 .

 

Do you want to add the sizes of C:\Users\Tom\Documents, C:\Users\Tom\Pictures and C:\Users\Tom\Music? Is the size of your C:\User\Tom 12.5GB the original data? So 2+3+1 is not equal to 12.5? What are top-level folders? Does it mean C:\Generic or C:\User\Tom?

 

First, create a calculated column to calculate the number of /:

\count =
LEN([Path]) - LEN(SUBSTITUTE([Path], "\", ""))

 

Second, create a calculated column to extract the Size from your original data. Because formats like 3GB are of String type and cannot be summed.

SizeNum =
FORMAT(LEFT(
     'Table'[Size],
     VALUE(
         LEN('Table'[Size]))-2),"Fixed")

 

Finally, create a measure to calculate the sum of Documents, Pictures, and Music.

SizeMeasure =
VAR _size = CALCULATE(SUM('Table'[SizeNum]),'Table'[\count] = 3)
RETURN IF(MAX('Table'[\count]) = 3,_size & "GB",BLANK())

 

The page effect is as follows:

vhuijieymsft_0-1716530819020.png

 

I set C:\Generic as top-level folders, that is, set Filter to 1 on the visual object.

 

The page effect is as follows:

vhuijieymsft_1-1716530819022.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @dinosainsburys ,

 

Thanks for the reply from rajendraongole1 .

 

Do you want to add the sizes of C:\Users\Tom\Documents, C:\Users\Tom\Pictures and C:\Users\Tom\Music? Is the size of your C:\User\Tom 12.5GB the original data? So 2+3+1 is not equal to 12.5? What are top-level folders? Does it mean C:\Generic or C:\User\Tom?

 

First, create a calculated column to calculate the number of /:

\count =
LEN([Path]) - LEN(SUBSTITUTE([Path], "\", ""))

 

Second, create a calculated column to extract the Size from your original data. Because formats like 3GB are of String type and cannot be summed.

SizeNum =
FORMAT(LEFT(
     'Table'[Size],
     VALUE(
         LEN('Table'[Size]))-2),"Fixed")

 

Finally, create a measure to calculate the sum of Documents, Pictures, and Music.

SizeMeasure =
VAR _size = CALCULATE(SUM('Table'[SizeNum]),'Table'[\count] = 3)
RETURN IF(MAX('Table'[\count]) = 3,_size & "GB",BLANK())

 

The page effect is as follows:

vhuijieymsft_0-1716530819020.png

 

I set C:\Generic as top-level folders, that is, set Filter to 1 on the visual object.

 

The page effect is as follows:

vhuijieymsft_1-1716530819022.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

rajendraongole1
Super User
Super User

Hi @dinosainsburys -Instead of manipulating strings directly in DAX is difficult, you can handle this in Power Query (M Language) to preprocess your data:

Add a Custom Column
IsTopLevelFolder = Text.Contains([Path], "\") = false

apply with filter rows where IsTopLevelFolder is true.
Close & Apply:

Apply the changes and load the data back into Power BI and then create a Measure for Sum the sizes of the filtered data.
DAX
TopLevelFolderSizeSum = SUM(Files[Size])

Check the above approach and let me know.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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