HASH
A 64-bit hash of one or more values, text regardless of case and 1 apart from 1.0; the numbers differ from Power BI's, whose algorithm is not published.
Group: Table manipulation. Compatible with DAX.
Syntax
HASH ( <value> [, <value>] … )
| Parameter | Type | Description |
|---|---|---|
value | Value repeatable | A value to include: a number, a text, a date, TRUE or FALSE, or a blank. |
Returns
Whole number. A 64-bit number that stands for the values, the same every time for the same values.
Remarks
- Text is hashed without regard to case: "Pils" and "PILS" give the same number.
- The type counts as well as the value: the whole number 1 and the decimal 1.0 hash apart.
- The order of the values counts too: swapping two of them gives another number.
- Two different inputs can, very rarely, share a number. Use it to compare rows or to build a compact key, not as proof that two values are equal.
Compared with DAX
Power BI has a HASH function as well, but it has not published how it computes it. OpenBI's numbers are therefore not Power BI's, while the rules above hold in both: never compare a hash made in one with a hash made in the other.
Examples
When two hashes are equal
EVALUATE
ROW (
"Same text, other case", HASH ( "Pils" ) = HASH ( "PILS" ),
"Other text", HASH ( "Pils" ) = HASH ( "IPA" ),
"1 and 1.0", HASH ( 1 ) = HASH ( 1.0 ),
"Order swapped", HASH ( "Pils", 2026 ) = HASH ( 2026, "Pils" )
)
| Same text, other case | Other text | 1 and 1.0 | Order swapped |
|---|---|---|---|
| TRUE | FALSE | FALSE | FALSE |
A key for each shop and product
EVALUATE
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE ( Sales, Sales[Shop], Sales[Product] ),
"Key", HASH ( Sales[Shop], Sales[Product] )
),
Sales[Shop] = "Shop Frogner"
)
ORDER BY Sales[Product]
| Sales[Shop] | Sales[Product] | Key |
|---|---|---|
| Shop Frogner | Cider | -6830723181193822675 |
| Shop Frogner | IPA | 1804212163383822059 |
| Shop Frogner | Lettøl | 6890630007113384451 |
| Shop Frogner | Pils | -7508975056107936528 |