Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
abfdjuk
Helper I
Helper I

currency conversion with budgeted rates

Hi.

 

I have two tables of data. One is the currency, year and exchange rate "ExchangeRates" the other is "Invoices" with colums for year, net amount and currency code. I have tried so many different formulas - all the ones I would use in excel don't seem to work! and keep hitting errors. The latest one I get is: a single value cannot be determined...

 

My question is how do I create a calculation which does does a currency conversion using the exchange rate in a set year from the "exchangeRates" table and then calculates this against the invoice amount?

 

many thanks for any help

 

abfdjuk_1-1667316395553.png

abfdjuk_2-1667316508298.png

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Converted amount =
SUMX (
    Invoices,
    Invoices[Net amount]
        * LOOKUPVALUE (
            ExchRate[Rate],
            ExchRate[Currency code], Invoices[Currency code],
            ExchRate[Year], Invoices[Year]
        )
)

View solution in original post

7 REPLIES 7
johnt75
Super User
Super User

Converted amount =
SUMX (
    Invoices,
    Invoices[Net amount]
        * LOOKUPVALUE (
            ExchRate[Rate],
            ExchRate[Currency code], Invoices[Currency code],
            ExchRate[Year], Invoices[Year]
        )
)

I just tried this and get the following error: Function 'LOOKUPVALUE' does not support comparing values of type Integer with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

 

yes, because YearCode in your table is of type "String" (text in PowerQuery) -> change it to integer (number in powerquery)

nks for your quick response. Now I get this error: A table of multiple values was supplied where a single value was expected. Any ideas what I need to change?

it looks like you have multiple entries for the same combination of year and currency code. 

Thanks for your help.

lukiz84
Memorable Member
Memorable Member

ConvertedSum = 
   VAR InvoiceDate = SELECTEDVALUE(Invoices[InvoiceDate])
   VAR Currency = SELECTEDVALUE(Invoices[Curreny])
   VAR ConversionRate = 
      CALCULATE(
         MIN(ConversionRates[rate]),
         ConversionRates[currency] = Currency, 
         ConversionRates[cear] = YEAR(InvoiceDate)
      )

   RETURN SUM(Invoices[Invoices - Net amount]) * ConversionRate
   

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.