HASH DAX Function
Compute hash over a variable number of input expressions and return a value.
Syntax
| Parameter | Attributes | Description |
|---|---|---|
| Expression | Repeatable |
The expression(s) for which the hash is computed. |
Return values
A 64-bit integer number. The number can be negative.
Remarks
The HASH function is not documented by Microsoft yet, but it appears in the Microsoft metadata.
HASH returns a 64-bit integer number that DAX computes from the values of all the arguments. The same values in the same order return the same number. The order of the arguments matters: HASH ( 1, “a” ) and HASH ( “a”, 1 ) return different numbers.
Each argument must be a scalar value. A table returns an error.
The data type of each value matters. For example, 1 (integer), 1.0 (decimal number), TRUE and “1” return different numbers. BLANK and 0 also return different numbers. Text values that DAX considers equal return the same number. HASH ignores the case and the trailing spaces: HASH ( “a” ), HASH ( “A” ) and HASH ( “a ” ) return the same number.
Different values can return the same number (a hash collision). Thus, do not use HASH as a unique key when a collision is not acceptable. Microsoft does not document the hash algorithm. Do not store hash values to compare them with values that a different version of the engine computes.
Examples
-- HASH returns a 64-bit integer for one or more values.
-- Text values that DAX considers equal have the same hash:
-- case and trailing spaces are ignored.
-- The data type matters: 1, 1.0, TRUE and "1" have different hashes.
-- The order of the arguments matters.
EVALUATE
SELECTCOLUMNS (
{
( 1, "HASH ( ""a"" ) = HASH ( ""A"" )", HASH ( "a" ) = HASH ( "A" ) ),
( 2, "HASH ( ""a"" ) = HASH ( ""a "" )", HASH ( "a" ) = HASH ( "a " ) ),
( 3, "HASH ( 1 ) = HASH ( 1.0 )", HASH ( 1 ) = HASH ( 1.0 ) ),
( 4, "HASH ( 1 ) = HASH ( TRUE () )", HASH ( 1 ) = HASH ( TRUE () ) ),
( 5, "HASH ( 1 ) = HASH ( ""1"" )", HASH ( 1 ) = HASH ( "1" ) ),
( 6, "HASH ( 1, ""a"" ) = HASH ( ""a"", 1 )", HASH ( 1, "a" ) = HASH ( "a", 1 ) ),
( 7, "HASH ( BLANK () ) = HASH ( 0 )", HASH ( BLANK () ) = HASH ( 0 ) )
},
"#", [Value1],
"Comparison", [Value2],
"Result", [Value3]
)
ORDER BY [#]
-- HASH can create one integer key for a combination of columns.
EVALUATE
VAR BrandColor =
SUMMARIZE ( 'Product', 'Product'[Brand], 'Product'[Color] )
VAR Keys =
SELECTCOLUMNS (
BrandColor,
"Key", HASH ( 'Product'[Brand], 'Product'[Color] )
)
RETURN
ROW (
"Combinations", COUNTROWS ( BrandColor ),
"Distinct keys", COUNTROWS ( DISTINCT ( Keys ) ),
"Key is an integer", ISINT64 ( MAXX ( Keys, [Key] ) )
)
| # | Comparison | Result |
|---|---|---|
| 1 | HASH ( “a” ) = HASH ( “A” ) | True |
| 2 | HASH ( “a” ) = HASH ( “a ” ) | True |
| 3 | HASH ( 1 ) = HASH ( 1.0 ) | False |
| 4 | HASH ( 1 ) = HASH ( TRUE () ) | False |
| 5 | HASH ( 1 ) = HASH ( “1” ) | False |
| 6 | HASH ( 1, “a” ) = HASH ( “a”, 1 ) | False |
| 7 | HASH ( BLANK () ) = HASH ( 0 ) | False |
| Combinations | Distinct keys | Key is an integer |
|---|---|---|
| 111 | 111 | True |
Last update: Nov 25, 2026 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo, Daniil Maslyuk
Microsoft documentation not available.
The function may be undocumented or unsupported. Check the Compatibility box on this page.