Тёмный

VLOOKUP with examples and search LEFT! 

Google: Apps, Script, Pillole, Tips and Tricks
Подписаться 4,9 тыс.
Просмотров 6 тыс.
50% 1

The VLOOKUP function, also known as VLOOKUP (if the sheet settings are in English) is typically used in Google Sheets to retrieve data from one table and add it to another. Apparently it seems complicated to apply however, once you understand how it works, it usually becomes one of the most used functions.
Let's see immediately what it does by applying it to a practical example.
From the table shown in the video, let's say we want to know the number of inhabitants of specific countries. Vertical search searches for a key across the first column of a defined range and returns the value of a specified cell in the found row.
This is the formula:
=VLOOKUP(G3, $B$3:$D$234.3, FALSE)
The expected parameters are therefore:
- the search key, which represents the value to be searched (explicitly defined, as "Italy" or with the reference to the relative cell);
- the second parameter is the interval to be considered for the search. Remember that the key will be searched in the first column of that range;
- then we have the index of the column of the value to be returned, where the first column has index 1, the second 2, the third 3 and so on;
- finally, we can specify if the list is sorted or not. A Boolean value (TRUE or FALSE) that indicates whether the column to be searched (the first column of the specified range) is sorted.
If set to FALSE:
the function verifies the exact correspondence with the value to search for;
it does not distinguish between uppercase and lowercase;
returns the content referring to the first match found even in the case of values repeated subsequently;
and if no match is found it returns N / A
If, on the other hand, the parameter is set to TRUE:
the function finds the closest match (less than or equal to) the search key.
Let's see what this concept means. Let's say we have the same table just created and that through an indicated value we want to find the country that has the closest number of inhabitants to this value. I invert the columns since VLOOKUP allows us to return data that is to the right of our reference value. In fact, this function does not natively allow you to search for values to the left of the first column of the range, however soon I'll show you how to overcome this limit with a little trick.
Returning to the example, I sort the values (it is important to underline that the sorting must be ascending, that is from the smallest to the largest value, otherwise an error will be returned, N / A) and at this point let's say we want to find the country with the number closest to 20 million.
The formula is as follows:
=VLOOKUP(K12, $G$13:$H$17, 2, TRUE)
Virtually identical to the previous one but with the fourth parameter set to TRUE. The result is precisely Chile, as it is the country on my list with the closest number of inhabitants to the one I was looking for.
A note: the parameter in question, the fourth note, can be omitted. In this case it would be interpreted as TRUE. However, because the vast majority of VLOOKUP use cases use FALSE, this value should be specified. 0 can also be used to indicate FALSE (hence 1 represents the numerical equivalent of TRUE).
If you are interested in learning more about the Boolean variables, I leave you the link to the dedicated lesson of my free course on simplified JavaScript for Google tools: • JavaScript Semplificat...
The last example that I show you, as anticipated, is how to be able to search for a value to the left of the first column, without having to physically invert the columns, as we did a little while ago and which is not a very convenient practice since it can make my table unintuitive starting point. It goes without saying that the country column form followed by the population column is certainly clearer than the one that sees the number of inhabitants before other information.
With a little trick we can tell the function to virtually sort the columns according to our needs. This is possible by creating a custom array using the braces {}.
I mean like this, where I'm telling the Sheet to create a range of 2 columns where the first column is the D and the second is the B.
={$D$ 2:$D$234, $B$2:$B$234}
However, inside VLOOKUP, I can insert it in place of the parameter relating to the interval, and this defines in a completely transparent way the structure of the new table in which to search, without the need to create a support table. So I can refer to a column that is after, in terms of position, compared to the one in which to retrieve the value and get the result. A trick that allows you to search with VLOOKUP to the left leaving the source table intact.
#GoogleSheets #Spreadsheet #cercavert

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 31   
@tommasocodolo
@tommasocodolo 6 месяцев назад
finalmente cacchio! Ho trovato vari tutorial in cui nessuno menzionava "false" alla fine della formula. E così la lista che prendevo da un menù a tendina era tutta sballata nei risultati. Grazie per la dritta anche se il tutorial è di 2 anni fa, utilissimo.
@_MagicMike
@_MagicMike 6 месяцев назад
Grazie a te del feedback e del commento! 🙂
@sergio_molinari
@sergio_molinari 2 года назад
Complimenti Michele, vista la tua Professionalità in diversi tuoi video ho acquistato il tuo libro, arrivato oggi. Ancora Complimenti!
@_MagicMike
@_MagicMike 2 года назад
Grazie del commento e della fiducia Sergio! 🙂 Sono certo che ti toglierai delle soddisfazioni con gli script 👍 Ti auguro una buona lettura e soprattutto buon divertimento! 💪
@temyraverdana6421
@temyraverdana6421 2 года назад
Anche oggi ho investito 10 minuti in conoscenza. Grazie e alla prossima
@_MagicMike
@_MagicMike 2 года назад
Grazie a te dell'interesse e del commento 🙂
@robertodicroce2463
@robertodicroce2463 Год назад
Spettacolare, la funzione con le parentesi graffe non la conoscevo. Molto utile. Grazie
@_MagicMike
@_MagicMike Год назад
Grazie a te Roberto per il commento e per il feedback! 🙂
@mauromattei9779
@mauromattei9779 7 месяцев назад
Salve Michele grazie molto utile
@_MagicMike
@_MagicMike 7 месяцев назад
Grazie Mauro! 🙂
@stefanotampieri4144
@stefanotampieri4144 2 года назад
La funzione delle Graffe è fantastica !
@_MagicMike
@_MagicMike 2 года назад
Confermo Stefano! Nel caso visto nel video come anche in qualsiasi altra situazione, indipendentemente dal coinvolgimento del CERCA.VERT, ti permette di raggruppare i valori delle celle in qualsiasi ordine senza bisogno di alterare la tabella di origine 🙂
@_MagicMike
@_MagicMike 2 года назад
Trovo che lo stratagemma di utilizzare le parentesi graffe per cercare il risultato verso sinistra sia davvero più semplice rispetto a combinare le funzioni MATCH e INDEX, sei d'accordo?
@lordia79
@lordia79 Месяц назад
Grazie mille un aiuto molto efficace
@_MagicMike
@_MagicMike Месяц назад
Grazie a te del feedback Lorenzo! 🙂
@martinocorti9496
@martinocorti9496 2 года назад
Buona sera, grazie per il video! Ho una domanda: esiste un modo, attraverso le formule, di eliminare da una stringa di testo i caratteri speciali, come apostrofi, accenti, spazi aggiuntivi? per lavoro ho necessità abbastanza spesso di confrontare fra loro liste di nominativi e cerca.vert tornerebbe molto utile, ma dalle prove che ho eseguito mi risulta che le stringhe da cercare devono essere esattamente uguali fra loro. Mi può aiutare? La ringrazio!
@_MagicMike
@_MagicMike 2 года назад
Ciao martino, grazie del feedback! 🙂 Per rimuovere i caratteri speciali da una stringa di testo in una cella tramite formula in Google Sheets puoi utilizzare REGEXREPLACE: support.google.com/docs/answer/3098245?hl=it
@TeNaMiK
@TeNaMiK Год назад
Buonasera, grazie per l'ottima spiegazione, io ho un problema di questo tipo, nella tabella di riferimento ci sono diversi valori che corrispondono al valore da cercare, e nella colonna da cui voglio visualizzare il risultato ci sono una serie di date, io vorrei che mi si visualizzasse sempre la data più recente. come posso fare? (esempio pratico, tabella con 4 colonne A=C.F. B=Cognome C=Nome D=Data (ci possono essere piu C.F. uguali nella colonna A con Date diverse nelle colonna D); in un altro foglio Voglio che cercando il C.F. mi compaia la data più recente). Grazie per la risposta! Se hai bisogno di chiarimenti contattami pure. Grazie ancora
@_MagicMike
@_MagicMike Год назад
Ciao Michele, grazie del feedback! Per trovare il valore con la data più recente puoi provare a combinare le funzioni INDICE, CONFRONTA e MAX.
@TeNaMiK
@TeNaMiK Год назад
@@_MagicMike oK, grazie per il suggerimento, l'ho provato in svariati modi, avresti un suggerimento di come impostare la formula?
@_MagicMike
@_MagicMike Год назад
@@TeNaMiK qualcosa di simile a questo (non è riferito alle celle che hai indicato, deve essere adattato): =INDEX(C3:C26,MATCH(MAX(D3:D26),D3:D26,0)) Dove: D3:D26 è la colonna della data, MAX (D3: D26) troverà la data più recente nella colonna della data e MATCH (MAX (D3:D26), D3:D26,0) calcolerà il numero di riga dell'ultima data nella colonna della data. C3:C26 è la colonna in cui troverai il valore.
@TeNaMiK
@TeNaMiK Год назад
@@_MagicMike ho risolto in questo modo, è stata molto dura ma alla fine funziona benissimo ti lascio l'esempio: =ArrayFormula(MAX(SE('FOGLIO 2'!$A$4:$A$10000=A6;'FOGLIO 2'!$E$4:$E$10000))). Nella colonna A ho tutti codici fiscali (su entrambi i fogli), mentre nella colonna E del foglio 2 ho le date che mi interessano, Sul foglio 1 voglio che mi compaia la data più recente che va a pescarsi tra le tante del foglio 2 che corrispondano però al C.F. interessato. Nella tua formula mancava il confronto con la cella del C.F. in cui mi interessava avere il risultato della data più recente. Capisco anche che senza un foglio vero e proprio come esempio sia difficile da capire la situazione. comunque grazie mille per la disponibilità e complimenti ancora per il tuo canale! Buona serata
@_MagicMike
@_MagicMike Год назад
@@TeNaMiK Grazie 1000 Michele del riscontro e di aver portato qua la tua soluzione con spiegazione! 💪🙂 Questo è lo spirito di una vera community! 🔝
@pierluigicastallo3895
@pierluigicastallo3895 Год назад
Complimenti Michele! (ho comprato il tuo libro...bravo davvero!) Anch'io ho lo stesso problema di @riccardocontessi
@_MagicMike
@_MagicMike Год назад
Grazie Pierluigi! Hai verificato se il problema è dovuto ai casi che ho descritto in risposta al commento che hai menzionato?
@pierluigicastallo3895
@pierluigicastallo3895 11 месяцев назад
@@_MagicMike Grazie mille della tua risposta, ho controllato più volte ma ho fatto come spieghi nel video. Ho notato però che al min 5:56 dici di utilizzare come separatore all'interno della formula il " punto&virgola" ma da video si vede che inserisci la "virgola". Quindi inserendo la "virgola" e localizzando il file nel Regno Unito la formula funziona correttamente. Inserendo invece alla stessa formula il "punto&virgola" i valori vengono riportati su un unica colonna. (se non si localizza il file nel Regno Unito, la formula da ERRORE.
@riccardocontessi
@riccardocontessi Год назад
Buonasera Michele, ho digitato la funzione cerca.vert con la matrice ma come risultato mi riporta #VALORE! (in ARRAY_LITERAL mancano i valori in un'espressione literal della matrice per una o più righe). Anche quando prova a digitare la formula con il solo array anziché riportare i dati su due colonne, crea una sola colonna prima con i valori della colonna "D" poi con i valori della colonna "B". Sbaglio qualcosa?
@_MagicMike
@_MagicMike Год назад
Ciao Riccardo, sicuramente da qualche parte c'è un'incingruenza tra i dati e le formule. Prova a fornire maggiori dettagli sulla formula e sui dati in modo da poter provare a replicare la situazione 👍
@riccardocontessi
@riccardocontessi Год назад
@@_MagicMike Buongiorno Michele, perdonami non ti ho fatto nemmeno i complimenti per il lavoro che fai. Innanzitutto grazie! Diciamo che ho seguito pedissequamente il video in modo da replicare dati e formule così come le vedevo nel tuo video. Diciamo che fino all'utilizzo di cerca.vert con ricerca verso sinistra non ho avuto problemi. Quando invece ho inserito l'array con le parentesi graffe ={D1:D212;B1:B212} anziché come nel tuo esempio in cui vengono popolate le colonne "N" ed "O" a me popola solo un'unica colonna la "N" con i risultati incolonnati (scusa il gioco di parole) della colonna "D" e della colonna "B". Quando inserisco la formula cerca.vert =CERCA.VERT(K3;{$D$2:$D$212;$B$2:$D$212};1;0) mi da questo risultato #VALORE! (in ARRAY_LITERAL mancano i valori in un'espressione literal della matrice per una o più righe). L'unica differenza rispetto al tuo foglio di lavoro è la riga 1. Io ho fatto partire le intestazioni dalla prima riga. Spero di essere stato più preciso. Grazie e buona giornata
@_MagicMike
@_MagicMike Год назад
@@riccardocontessi quell'errore solitamente viene restituito quando si applica la formula ad una situazione dove sono state unite le colonne e non tutte le celle erano valorizzate. Farei un controllo se questo è il caso.
@riccardocontessi
@riccardocontessi Год назад
@@_MagicMike Grazie della risposta. Faccio un controllo. Buona serata
Далее
Fogli Google - Rimuovi le righe Duplicate con UNIQUE
2:26
Google Sheets Formulas Tutorial
23:25
Просмотров 381 тыс.
СМЕЛОЕ РЕШЕНИЕ #shorts
00:14
Просмотров 23 тыс.
Google Sheets - Learn to use QUERY and that's it!
5:42
Cerca Vert in Google Sheet (fogli): Usalo COSÌ!
9:44
Просмотров 1,7 тыс.
Spreadsheet GDrive - tabelle pivot e query
27:23
Просмотров 7 тыс.