HASH DAX Function

Compute hash over a variable number of input expressions and return a value.

Syntax

HASH ( <Expression> [, <Expression> [, … ] ] )
Parameter Attributes Description
Expression Repeatable

The expression(s) for which the hash is computed.

Return values

Scalar A single integer value.

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.

2018-2026 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Passed by Expression

This parameter is passed by expression and can be evaluated multiple times in different evaluation contexts.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of HASH? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.