Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Byte Formatting

Hello,

after I couldn't find some hints in the QV-Documentation and in this forum, i ask my question here.

Is there a possibilty to format with a Number which represents bytes in a human readable way?

For example:

xxx Bytes are xxx KBytes or xxx MByte or xxx MByte

Or maybe someone has written a small formula or something.

Thanks

Christoph

1 Solution

Accepted Solutions
Not applicable
Author

Hi Christoph,

Using the Hans' option, there's a formula to answer your problem :

=If(
div(div(div(sum([Number]),1024),1024),1024)>0,div(div(div(sum([Number]),1024),1024),1024)&' G',
If(div(div(sum([Number]),1024),1024)>0,div(div(sum([Number]),1024),1024)&' M',
If(div(sum([Number]),1024)>0,div(sum([Number]),1024)&' K',sum([Number)&' ')))&'Bytes'

Eric.

View solution in original post

4 Replies
Not applicable
Author

Hi,

1 MByte is 1024 KBytes
1 KByte is 1024 Bytes

So the following expression would give you the answer:

=Number &' Bytes are ' & Number/1024 & ' KBytes or ' & Number/1024/1024 & ' MBytes'

BR

Hans

Not applicable
Author

Hi Hans,

thanks for your anwser. Sure this is maybe an option.

I'm searching for a solution where, if the bytes varies between kBytes, MBytes, GBytes and so on, the formula chooses the ideal measurement unit.

greets

Christoph

Not applicable
Author

Hi Christoph,

Using the Hans' option, there's a formula to answer your problem :

=If(
div(div(div(sum([Number]),1024),1024),1024)>0,div(div(div(sum([Number]),1024),1024),1024)&' G',
If(div(div(sum([Number]),1024),1024)>0,div(div(sum([Number]),1024),1024)&' M',
If(div(sum([Number]),1024)>0,div(sum([Number]),1024)&' K',sum([Number)&' ')))&'Bytes'

Eric.

Not applicable
Author

Hi Eric,

thanks for your code. It got me to the right direction.
I modified it a little bit, because I wanted to see the decimal.

Thanks


=If(div(div(div(sum([Number]),1024),1024),1024) >0,
num(sum([Number] / 1024 / 1024 / 1024), '#.##0,00') &' G',
If(div(div(sum([Number]),1024),1024)>0,
num(sum([Number] / 1024 / 1024), '#.##0,00') &' M',
If(div(sum([Number]),1024)>0,
num(sum([Number] / 1024), '#.##0,00') & ' K',
sum([Number]) & ' ' ))) & 'Bytes'