Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

using SWITCH() Formula in Google Sheets using hash-map

In my Google Sheet table, I use SWITCH command to convert a cell from coin symbol -> into coin value.

what I currently do:

=SWITCH(D660,"₪","ILS","$","USD","Ft","HUF","€","EUR","лв","BGN","£","EGP")

this will convert cell D660 from coin symbol (₪/$/Ft/€/лв/£) -> into coin name

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

here’s an example of my data:

where in column E I have the equation above.

what I want to do:

I want to a more generic way, where I have a "hash-map" table in my Settings tab which contains the following table:

coin_symbol coin_name
ILS
$ USD
Ft HUF
EUR
лв BGN
£ EGP

and now I want the =SWITCH(D660,...) to use the table instead of hard coding inserting the conversion table

.

I’m struggling on this one, I tried stuffs like
=SWITCH(D660,A1:A10,B1:B10) or involving ARRAYFORMULA somewhere but nothing worked.

anyone have a suggestion how to implement that?

>Solution :

You can use VLOOKUP()

In table with the coins symbols and value as you described ( where symbols is column A and name column B)

=VLOOKUP([SYMBOL];[A1:B6];2;FALSE)

Where:
Symbol is the symbol you want to replace ( you can use cell reference );
A1:B6 is the table you want to look in;
2 is the column in wich you take the value;
False as the values are not ordered by a number, just use false.

/!\ depending on your locatioon the ; in my formula might have to be replaced by ,

Here’s an example you could use

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading