Binary.Compress
BinaryCompresses a binary value using the specified compression type (GZip or Deflate).
Syntax
Binary.Compress(binary as nullable binary, compressionType as number) as nullable binaryParameters
| Name | Type | Required | Description |
|---|---|---|---|
binary | binary | Yes | The binary value to compress. |
compressionType | number | Yes | The compression algorithm to use: Compression.GZip or Compression.Deflate. |
Return Value
binary — A compressed copy of the input binary value.
Remarks
Binary.Compress compresses a binary value using the specified compression algorithm. The result is a compressed copy of the input. Supported compression types are:
Compression.GZip— GZip compression (RFC 1952). Produces output with a GZip header/trailer; commonly used for HTTP content encoding.Compression.Deflate— Deflate compression (RFC 1951). Produces raw compressed output without headers.
Use Binary.Decompress with the same compression type to reverse the operation. This pair of functions is useful for reducing the size of binary data for storage or transmission.
Examples
Example 1: Compress a binary value using Deflate
let
Source = Binary.FromList(List.Repeat({10}, 1000)),
Compressed = Binary.Compress(Source, Compression.Deflate),
OriginalSize = Binary.Length(Source),
CompressedSize = Binary.Length(Compressed)
in
#table({"OriginalBytes", "CompressedBytes"}, {{OriginalSize, CompressedSize}})Applied Steps
The final output — a single-row table comparing the original and compressed sizes.
OriginalBytes | CompressedBytes | |
|---|---|---|
| 1 | 1,000 | 11 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks