Home > Back-end >  How to use if-else in google sheets with currency?
How to use if-else in google sheets with currency?

Time:11-13

I have an issue where I am trying to make a comparison between values to see if A contains value then use that value and if B contains the value then use that value, something like this: Google sheet

My goal is that when I have resell pris (SEK) value, then I should just =SUM(O6-I6) in Totala profit but if I have in EURO then I want to convert the currency from euro to todays currency in SEK and calculate that for totala profit, meaning something like (100€ * swedish currency) - value in totala profit e.g. 1000.

My question is, is it possible to do that using google sheet? if so, how can I use the if else statement for that?

Expected:

Should take Resell pris SEK/EUR - totala profit depending on where we have the value. If we have in SEK then we do Resell pris SEK - Totala profit and if we have EURO then convert to SEK and then - totala profit.

Actual:

I only managed to make it work if there is a value in Resell pris (SEK)

CodePudding user response:

Use if() and regexmatch(), like this:

=(O6 - I6) * if( regexmatch(to_text(O6), "(?i)EUR|€"), R$1, 1 )

...where cell R1 gets the exchange rate with googlefinance(), like this:

=googlefinance("EURSEK")

  • Related