# autonumberhash256 - funzione di script

Questa funzione di script calcola un hash a 256 bit dei valori di espressione di input combinati e restituisce un valore intero univoco per ciascun valore hash distinto rilevato durante l'esecuzione dello script. Questa funzione può essere utilizzata per creare una rappresentazione compatta di memoria che rappresenta una chiave complessa.

Nota informaticaÈ possibile connettere solo chiavi autonumberhash256 che sono state generate nello stesso caricamento di dati, poiché il numero intero viene generato in base all'ordine di lettura della tabella. Se si necessita di utilizzare chiavi permanenti tra i caricamenti di dati indipendentemente dall'ordinamento dei dati sorgente è necessario utilizzare le funzioni hash128, hash160 o hash256.

Sintassi:

autonumberhash256(expression {, expression})

Esempio: Creazione di una chiave composita

Nell'esempio viene creata una chiave composita tramite la funzione autonumberhash256 per conservare la memoria. L'esempio è breve a scopo dimostrativo, ma risulterebbe significativo con una tabella contenente un elevato numero di righe.

Tabella di esempio

| Region | Year | Month | Sales |
| --- | --- | --- | --- |
| North | 2014 | May | 245 |
| North | 2014 | May | 347 |
| North | 2014 | June | 127 |
| South | 2014 | June | 645 |
| South | 2013 | May | 367 |
| South | 2013 | May | 221 |

I dati sorgente vengono caricati tramite dati inline. Quindi, è necessario aggiungere un caricamento precedente, che crea una chiave composita dai campi Region, Year e Month.

```
RegionSales:
LOAD *,
AutoNumberHash256(Region, Year, Month) as RYMkey;

LOAD * INLINE
[ Region, Year, Month, Sales
North,	2014,	May,	245
North,	2014,	May,	347
North,	2014,	June,	127
South,	2014,	June,	645
South,	2013,	May, 367
South,	2013,	May,	221
];
```

La tabella risultante avrà l'aspetto seguente:

Tabella dei risultati

| Region | Year | Month | Sales | RYMkey |
| --- | --- | --- | --- | --- |
| North | 2014 | May | 245 | 1 |
| North | 2014 | May | 347 | 1 |
| North | 2014 | June | 127 | 2 |
| South | 2014 | June | 645 | 3 |
| South | 2013 | May | 367 | 4 |
| South | 2013 | May | 221 | 4 |

In questo esempio è possibile fare riferimento a RYMkey, per l'esempio 1, anziché alla stringa 'North2014May' se si desidera effettuare il collegamento a un'altra tabella.

Ora viene caricata una tabella sorgente dei costi in modo simile. I campi Region, Year e Month vengono esclusi nel caricamento precedente per evitare di creare una chiave sintetica. È stata già creata una chiave composita con la funzione autonumberhash256 tramite il collegamento delle tabelle.

```
RegionCosts:
LOAD Costs,
AutoNumberHash256(Region, Year, Month) as RYMkey;

LOAD * INLINE
[ Region, Year, Month, Costs
South,	2013,	May,	167
North,	2014,	May,	56
North,	2014,	June,	199
South,	2014,	June,	64
South,	2013,	May, 172
South,	2013,	May,	126
];
```

Ora è possibile aggiungere la visualizzazione di una tabella a un foglio e aggiungere i campi Region, Year e Month così come le misure Sum per le vendite e i costi. La tabella avrà il seguente aspetto:

Tabella dei risultati

| Region | Year | Month | Sum([Sales]) | Sum([Costs]) |
| --- | --- | --- | --- | --- |
| Totals | - | - | 1952 | 784 |
| North | 2014 | June | 127 | 199 |
| North | 2014 | May | 592 | 56 |
| South | 2014 | June | 645 | 64 |
| South | 2013 | May | 588 | 465 |

## Ulteriori informazioni

* [autonumberhash128 - funzione di script](https://help.qlik.com/it-IT/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/CounterFunctions/autonumberhash128.htm)
* [autonumber - funzione di script](https://help.qlik.com/it-IT/sense/November2024/Subsystems/Hub/Content/Sense_Hub/Scripting/CounterFunctions/autonumber.htm)