0

Formula to select an exchange rate based on currency and date of payment

Hi everyone,

New day, new Ninox puzzle :)

 

I have a series of fields in a subtable recording past exchange rates for a series of currencies (we use InforEuro, so these are monthly exchange rates). I would like to use these rates in different places across the table, including to automatically select the appropriate exchange rate from other currencies to CHF in my payment tracking tool. I need a formula that, based on the currency and date of payment, picks the appropriate value across all the currencies and months recorded in my subtable.

 

For some reason, however, I can't even manage to accomplish the first step of the formula creation. I have a formula field; if I select the relevant subtable field 'Exchange rates'.'EUR->CHF 2019/01' the formula field just remains blank. What am I missing? EUR->CHF 2019/01 is a simple number field.

 

Once this is solved, I have an idea of how the formula could work but I wonder if it could be optimized. Something like this:

if 'Donor Currency' = "1" then
if 'Date of receipt #9' > date(2019, 1, 1) and < date(2019, 1, 31) then
'Exchange rates'.'EUR->CHF 2019/01'
else
if 'Date of receipt #9' > date(2019, 2, 1) and < date(2019, 2, 28) then
'Exchange rates'.'EUR->CHF 2019/02'
else
if 'Donor Currency' = "2" then
...

 

All suggestions welcomed and appreciated.

 

Best,

Giovanni

3 replies

null
    • Chapel_of_Praise
    • 3 yrs ago
    • Reported - view

    There is a great learning tutorial from Nioxus called "700.04 - Global Functions and Variables" that covers a function for currency conversion. May be overkill for what you want, but I found it very useful. https://youtu.be/psPLrRX2_AA 

    • Giovanni_Zagarella
    • 3 yrs ago
    • Reported - view

    Thank you Chapel of praise - the tutorial is definitely interesting and I learned something useful about global functions.

     

    Unfortunately it's not what I'm looking for though, since we need to have access to historical rates as well and not only to the most recent available conversion rate. Would anyone have a suggestion for the question posted above?

    • Compleasy
    • silver_bee
    • 3 yrs ago
    • Reported - view

    I have one table for daily exchange rates (exrates) with dates and exchange rates for a selection of currencies. In my order table, I have a date field and my currencies are listed in choice field. then I have a lookup field from exrates, with contraint exrates.date = order.date. Then I have a formula field for the actual exchange rate, where the visible result is based on the choice currency, e.g. if choice=1 then 'exrates.eur'

Content aside

  • 3 yrs agoLast active
  • 3Replies
  • 524Views