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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Jeff2Jets
Helper II
Helper II

Using 'Format Code' for custom 'Display Units'.

I have a Bar Chart that shows the total size (in bytes) for each status of a project. Is there a formula I can create to display the values in KB, MB, GB, TB, etc. For example, if the size is 10485760, I want to display 10.00 MB. Below is a reference to where I hope to supply the custom formatting.

Jeff2Jets_0-1742220221137.png

 

Thanks in advance!

7 REPLIES 7
v-hashadapu
Community Support
Community Support

Hi @Jeff2Jets ,
I wanted to follow up and see if you’ve had a chance to review the information provided here.
If any of the responses helped solve your issue, please consider marking it "Accept as Solution" and giving it a 'Kudos' to help others easily find it.
Let me know if you have any further questions!

v-hashadapu
Community Support
Community Support

Hi @Jeff2Jets , Thank you for reaching out to the Microsoft Community Forum.


Please try below and tell me if it works, If it doesn't, please share the sample file with data.

Formatted Size =
VAR SizeInBytes = SELECTEDVALUE('Table'[Size in Bytes], SUM('Table'[Size in Bytes]))
VAR UnitIndex =
MIN(
4,
FLOOR(
IF(SizeInBytes > 0, LOG(ABS(SizeInBytes), 1024), 0),
1
)
)
VAR ConvertedSize =
DIVIDE(SizeInBytes, POWER(1024, UnitIndex), 0)
VAR Unit =
SWITCH(
UnitIndex,
0, "Bytes",
1, "KB",
2, "MB",
3, "GB",
4, "TB"
)
RETURN
IF(
ISBLANK(SizeInBytes),
BLANK(),
FORMAT(ConvertedSize, "0.00") & " " & Unit
)

If this helped solve the issue, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details, always happy to help.
Thank you.

Jeff2Jets
Helper II
Helper II

Thanks for the input, but none of the methods you suggested can do what I need. I want to be able to display values in a matrix that are auto-formatted using KB, MB, GB, or TB. For example, if there is a size column in a matrix that has the number of Bytes, I want to have a formula that can dynamically convert the number of Bytes to the proper power of 1024 (K). If one row has a size of 10,726,932 Byyes, I want the column to display 10.23 MB. If the next row has a size of 1,452,856,985 Bytes, I want the column to display 1.35 GB. Is there a way to do this and if so, please include an example of how.

v-hashadapu
Community Support
Community Support

Hi @Jeff2Jets , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @Jeff2Jets , Please let us know if your issue is solved. If it is, consider marking the answer that helped 'Accept as Solution', so others with similar queries can find it easily. If not, please share the details.
Thank you.

v-hashadapu
Community Support
Community Support

Hi @Jeff2Jets , Thank you for reaching out to the Microsoft Community Forum.

Please let us know if your issue is solved. If it is, consider marking the answers that helped 'Accept as Solution', so others with similar queries can find them easily. If not, please share the details.
Thank you.

amitchandak
Super User
Super User

@Jeff2Jets , You have use Format option in measure

Visual Level Format Strings

https://youtu.be/A23Sof2CFMQ

 

More example

https://powerbi.microsoft.com/en-us/blog/power-bi-august-2024-feature-summary/#post-27820-_Toc174544...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors