Returns a hash value for the input value.


hash(source [, mod])


  • source: The value to be hashed.
  • mod: An optional module value to be applied to the hash result, so that the output value is between 0 and mod - 1


The hash value of the given scalar, modulo the given mod value (if specified).


The algorithm used to calculate the hash is xxhash. This algorithm might change in the future, and the only guarantee is that within a single query all invocations of this method use the same algorithm. Consequently, you are advised not to store the results of hash() in a table. If persisting hash values is required, use hash_sha256() or hash_md5() instead. Note that these functions are more complex to calculate than hash()).


hash("World")                   // 1846988464401551951
hash("World", 100)              // 51 (1846988464401551951 % 100)
hash(datetime("2015-01-01"))    // 1380966698541616202

The following example uses the hash function to run a query on 10% of the data, It is helpful to use the hash function for sampling the data when assuming the value is uniformly distributed (In this example StartTime value)

| where hash(StartTime, 10) == 0
| summarize StormCount = count(), TypeOfStorms = dcount(EventType) by State 
| top 5 by StormCount desc