SOLVED

Generalized currency conversion

%3CLINGO-SUB%20id%3D%22lingo-sub-2762714%22%20slang%3D%22en-US%22%3EGeneralized%20currency%20conversion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762714%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20community!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20modified%20setup%20as%20figure%20below.%20I%20want%20to%20generalize%20my%20currency%20conversion%20to%20SEK%20from%20different%20currencies%20(not%20limited%20to%20the%20ones%20listed%20below).%20In%20other%20words%2C%20I%20want%20the%20same%20formula%20in%20C11%20and%20downwards%20using%20the%20information%20provided.%20You%20can%20see%20some%20examples%20how%20the%20conversion%20is%20executed%20today%20in%20cells%20C11-C14.%20As%20you%20can%20see%2C%20most%20of%20the%20data%20is%20already%20in%20SEK%20and%20needs%20no%20conversion.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20not%20very%20good%20myself%20with%20this%20kinds%20of%20formulas%2C%20and%20would%20appreciate%20some%20input%20from%20the%20community.%20If%20there%20is%20a%20way%20to%20solve%20this%20without%20even%20using%20the%20ticker-rows%2C%20that%20would%20be%20even%20better!%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThanks%20in%20advance%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3EQWeelon%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22QWeelon_0-1631949014599.png%22%20style%3D%22width%3A%20674px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F311226i87B17C0FE73E5D69%2Fimage-dimensions%2F674x370%3Fv%3Dv2%22%20width%3D%22674%22%20height%3D%22370%22%20role%3D%22button%22%20title%3D%22QWeelon_0-1631949014599.png%22%20alt%3D%22QWeelon_0-1631949014599.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2762714%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2762737%22%20slang%3D%22en-US%22%3ERe%3A%20Generalized%20currency%20conversion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762737%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F912606%22%20target%3D%22_blank%22%3E%40QWeelon%3C%2FA%3E%26nbsp%3BSince%20you%20tagged%20your%20question%20with%20Office365%2C%20I%20assume%20your%20Excel%20version%20supports%20XLOOKUP.%20The%20attached%20workbook%20contains%20a%20mock-up%20based%20on%20your%20picture.%20See%20if%20it%20works%20for%20you%20and%20if%20you%20can%20implement%20it%20in%20your%20real%20life%20workbook.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBy%20the%20way%2C%20you'll%20notice%20that%20I%20included%20one%20extra%20currency%2C%20the%20SEK%2C%20in%20the%20lookup%20table%20at%20the%20top%20with%20a%20rate%20of%201.00.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2762770%22%20slang%3D%22en-US%22%3ERe%3A%20Generalized%20currency%20conversion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762770%22%20slang%3D%22en-US%22%3EThank%20you%20for%20your%20reply!%3CBR%20%2F%3E%3CBR%20%2F%3EYes%2C%20i'm%20currently%20in%20Office365%20but%20unfortunately%20I'm%20not%20able%20to%20get%20it%20to%20work%20-%20probably%20because%20of%20the%20table%20formulas%2C%20it%20is%20not%20something%20I'm%20familiar%20with%20at%20the%20moment.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20tried%20to%20augment%20the%20formula%20to%20the%20following%20without%20success%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3DXLOOKUP(A11%2CB4%3AB7%2CC4%3AC7%2C%22!%22%2C0)*B11%3CBR%20%2F%3E%3CBR%20%2F%3EDo%20I%20need%20to%20create%20tables%20for%20it%20to%20work%20properly%3F%20If%20Yes%2C%20how%20do%20I%20do%20in%20a%20way%20that%20they%20are%20compatible%3F%20(Never%20really%20worked%20with%20tables%20unless%20I%20needed%20to%20sort%20something%2C%20which%20is%20very%20rarely).%3CBR%20%2F%3E%3CBR%20%2F%3ESorry%20for%20the%20inconvienience%3CBR%20%2F%3E%3CBR%20%2F%3E%2FQ%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2762795%22%20slang%3D%22en-US%22%3ERe%3A%20Generalized%20currency%20conversion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762795%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F912606%22%20target%3D%22_blank%22%3E%40QWeelon%3C%2FA%3E%26nbsp%3BAlmost%20correct.%20You%20need%20to%20make%20the%20references%20to%20the%20lookup%20array%20and%20the%20return%20array%20absolute%2C%20using%20%24%20signs.%3C%2FP%3E%3CP%3ERemoved%20the%20table%20style%20in%20the%20attached%20workbook%2C%20so%20that%20you%20can%20see%20what%20I%20mean.%20Though%2C%20I'd%20recommend%20to%20learn%20about%20structured%20tables.%20The%20will%20make%20your%20Excel-life%20a%20lot%20easier.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETrevlig%20helg!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2762819%22%20slang%3D%22en-US%22%3ERe%3A%20Generalized%20currency%20conversion%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2762819%22%20slang%3D%22en-US%22%3ETo%20be%20honest%2C%20I%20have%20no%20idea%20why%20it%20don't%20work%20without%20the%20%24%2C%20never%20thought%20it%20was%20something%20necessary%20unless%20you%20need%20to%20lock%20cell%20-%20I%20usually%20add%20them%20after%20getting%20the%20formulas%20to%20work.%20Anyway%2C%20it%20works%20like%20a%20charm!%20Great!%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you%20very%20much!%3CBR%20%2F%3E%3CBR%20%2F%3EMaybe%20I'll%20watch%20a%20excel%20tutorial%20on%20structured%20tables%20on%20a%20rainy%20work%20days%20(I%20rarely%20use%20Excel%20in%20my%20work%20so%20this%20is%20just%20a%20'hobby').%20Do%20you%20have%20any%20videos%20to%20recommend%3F%3CBR%20%2F%3E%3CBR%20%2F%3EHowever%2C%20for%20my%20current%20setup%2C%20it%20is%20important%20for%20things%20to%20be%20scalable%2C%20i.e%20I'm%20continuously%20adding%20rows%20every%20week%20and%20I%20want%20to%20do%20this%20without%20adjusting%20a%20table%20every%20time.%3CBR%20%2F%3E%3CBR%20%2F%3EAnyhow%2C%20thank%20you%20again%20for%20your%20help!%20It%20is%20much%20appreciated!%3CBR%20%2F%3E%3CBR%20%2F%3ERegards%3CBR%20%2F%3E%2FQ%3C%2FLINGO-BODY%3E
Contributor

Dear community!

 

I have a modified setup as figure below. I want to generalize my currency conversion to SEK from different currencies (not limited to the ones listed below). In other words, I want the same formula in C11 and downwards using the information provided. You can see some examples how the conversion is executed today in cells C11-C14. As you can see, most of the data is already in SEK and needs no conversion.

 

I'm not very good myself with this kinds of formulas, and would appreciate some input from the community. If there is a way to solve this without even using the ticker-rows, that would be even better!


Thanks in advance

 

Regards

QWeelon

 

QWeelon_0-1631949014599.png

 

9 Replies

@QWeelon Since you tagged your question with Office365, I assume your Excel version supports XLOOKUP. The attached workbook contains a mock-up based on your picture. See if it works for you and if you can implement it in your real life workbook. 

 

By the way, you'll notice that I included one extra currency, the SEK, in the lookup table at the top with a rate of 1.00.

 

 

Thank you for your reply!

Yes, i'm currently in Office365 but unfortunately I'm not able to get it to work - probably because of the table formulas, it is not something I'm familiar with at the moment.

I tried to augment the formula to the following without success:

=XLOOKUP(A11,B4:B7,C4:C7,"!",0)*B11

Do I need to create tables for it to work properly? If Yes, how do I do in a way that they are compatible? (Never really worked with tables unless I needed to sort something, which is very rarely).

Sorry for the inconvienience

/Q
best response confirmed by QWeelon (Contributor)
Solution

@QWeelon Almost correct. You need to make the references to the lookup array and the return array absolute, using $ signs.

Removed the table style in the attached workbook, so that you can see what I mean. Though, I'd recommend to learn about structured tables. The will make your Excel-life a lot easier.

 

Trevlig helg!

To be honest, I have no idea why it don't work without the $, never thought it was something necessary unless you need to lock cell - I usually add them after getting the formulas to work. Anyway, it works like a charm! Great!

Thank you very much!

Maybe I'll watch a excel tutorial on structured tables on a rainy work days (I rarely use Excel in my work so this is just a 'hobby'). Do you have any videos to recommend?

However, for my current setup, it is important for things to be scalable, i.e I'm continuously adding rows every week and I want to do this without adjusting a table every time.

Anyhow, thank you again for your help! It is much appreciated!

Regards
/Q
Noterade precis din svenska! Haha! Trevlig helg och tusen tack!

@QWeelon Var så god! Hela poängen med struktrerade tabeller är ju att du inte behöver ora dig när du lägger till några rader med valuta kurser. Allt uppdateras då automatisk utan att man måste skriva om alle formel som pekar till dessa valuta kurser.  Men förstår vad du menar. Det ser inte så lätt ut om man inte är van med sådana tabeller.

@QWeelon 

One more variant is to use STOCKHISTORY function (microsoft.com) if it is available for your subscription.

 

Function returns exchange rates in the specified period, e.g.

=STOCKHISTORY("EUR/SEK",TODAY()-5, TODAY(), 0, 0, 1, 0)

returns EUR/SEK exchange rate for the latest 5 days. If interval is just TODAY() it returns current exchange rate - if only we have trading today. Function skips days without trading and if there are only such days within interval we have an error. Thus we need to take some range and take exchange rate for the latest trading date. Since function returns data from oldest to newest dates we need to sort returned array by date in descending order to have latest date on first position.

=SORT( STOCKHISTORY("EUR/SEK",TODAY()-5, TODAY(),0,0,1,0), 2, -1)

Now we don't need dates any more, only take the latest exchange rate

=INDEX( SORT( STOCKHISTORY("EUR/SEK",TODAY()-5, TODAY(),0,0,1,0), 2, -1), 1, 1)

 

Finally for such pattern

image.png

we apply currency format to column D, skip conversion if it is not required (initial price is in SEK) and apply above formula overwise to multiply price on exchange rate:

= IF( $B3 = "SEK", $C3, $C3 * INDEX( SORT(  STOCKHISTORY($B3 &  "/SEK",TODAY()-5, TODAY(),0,0,1,0), 2,-1), 1, 1) )

Please check in attached file.

Interesting. I'm currently using the Excel Stock function for currency data, but it requires manual updates to acquire the latest (15 min delay) the latest rates.

I'll have to look further into this to determine if this might be favourable for me!

Thanks!

@QWeelon 

If you need current exchange rate that doesn't work. STOCKHISTORY() has an option to show it on open, close, high and low for each day in interval.

 

Stock data type is updating constantly, thus you have the latest exchange rate for now. Not sure about delay in data, perhaps yes, 15 minutes. On the other hand you can't use currency pair as parameter here, it is predefined.

 

As for the refresh, option is coming for Excel. Not it is available for Beta version, it looks like

image.png