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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculated column returning a single value based on filters from two other columns

Hi, 

 

Another hopefully Quick QU... 

 

I have a table of exchange rates and another table of sales that contain a Currency ID, for example, USD, GBP, EUR and a Transaction Date that contains the Year which corresponds with the year in the exchanges rate table. 

 

What I want to do is create a calculated column where it pulls in the exchange rate based on the Currency ID in the sales table and the Transaction Year. 

 

Exchange Rate Table.PNG

Then on the sales data table, there is the transaction column and a currency column which matches the currency ID table pictured 

 

What I have pictured is almost like an if statement 

If SalesTable[CurrencyID]=ExchangeRate[CurrencyID] && SalesTable[TransactionDate].Year=ExchangeRate[Year].Year return the ExchangeRate[Value] 

 

Seems so simple but is throwing me a massive spanner in the works. 

 

Ultimately this is to turn a multiple currency reports into a single $USD Value report using the exchange rate average from the same year as the transaction date year. 

 

Thanks again in advance, 

 

Josh

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

First, add a calculated column in exchange rate table to get the average of exchange rate per year per currency.

Average rate =
CALCULATE (
    AVERAGE ( ExchangeRate[Rate] ),
    ALLEXCEPT (
        ExchangeRate,
        ExchangeRate[CurrencyID],
        ExchangeRate[Year]
    )
)


Then, add a calculated column in sales table to return the proper rate value which matches the Currency ID and Transaction Year.

Rate =
LOOKUPVALUE (
    ExchangeRate[Average rate],
    ExchangeRate[CurrencyID], SalesTable[CurrencyID],
    ExchangeRate[Year], SalesTable[TransactionDate].YEAR
)


Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

First, add a calculated column in exchange rate table to get the average of exchange rate per year per currency.

Average rate =
CALCULATE (
    AVERAGE ( ExchangeRate[Rate] ),
    ALLEXCEPT (
        ExchangeRate,
        ExchangeRate[CurrencyID],
        ExchangeRate[Year]
    )
)


Then, add a calculated column in sales table to return the proper rate value which matches the Currency ID and Transaction Year.

Rate =
LOOKUPVALUE (
    ExchangeRate[Average rate],
    ExchangeRate[CurrencyID], SalesTable[CurrencyID],
    ExchangeRate[Year], SalesTable[TransactionDate].YEAR
)


Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

maybe by creating a new dax measure and giving each type of currency ID a certain value, you can then create your argument for the data you want to present.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.