Forum Discussion

CM_Mills's avatar
CM_Mills
Icon for Helper II rankHelper II
11 months ago
Solved

FX Rate Connections

Hi,

 

I’m trying to add FX to my power BI dashboard.

 

Currently the data we need outputs from sits in a data table. I use a unique identifier to connect this to data tags to add more information. One of these tags is Currency.

 

The data table has the date in the table but the data tags table does not have any dates.

 

There is also a separate Date Table linked

 

I have a new FX table that includes FX Rates for several currencies per each date.

 

I’m struggling to link the FX table to rest of my data table so I can select a data output and it links the correct FX rate for the correct day.

 

My tables: 

 

Data Table

Data

Date

Data Unique Identifier

 

Data Tags

Data Unique Identifier

Data Currency

 

Date Table

Dates

 

FX Table

FX Rate

Dates

FX Currency (From)

  • I would combine the data table and the data tags table so that there is only 1 table with both the value and the currency. This is likely to make your measures much simpler and more efficient.

    I would also suggest reading https://www.daxpatterns.com/currency-conversion/ which goes into quite a bit of detail and has several code snippets which you may be able to adapt to your model.

  • Hi CM_Mills 

     

    Try the following measure:

    Converted to FX = 
    SUMX (
        ADDCOLUMNS (
            SUMMARIZECOLUMNS (
                Dates[Date],
                DataTags[Data Currency],
                "@lc", CALCULATE ( SUM ( 'DataTable'[LC] ) )
            ),
            "@converted",
                DIVIDE (
                    [@lc],
                    LOOKUPVALUE (
                        FXRates[FX Rate],
                        FXRates[Dates], [Date],
                        FXRates[FX Currency (From)], [Data Currency]
                    )
                )
        ),
        [@converted]
    )
    

    Please see the attached pbix.

  • Hi CM_Mills 

    In your model, the challenge comes from the fact that your FX table has both date and currency, while your main Data Table has date but the currency information only exists in the separate Data Tags table. Since the Data Tags table doesn’t contain dates, you can’t directly relate it to the FX table. The correct approach is to bridge these relationships: link the Data Table to the Date Table on the Date field, link the FX Table to the Date Table on Dates, and link the Data Table to Data Tags on the Unique Identifier. This way, your Data Table provides both the transaction date and, via the Data Tags, the relevant currency. To pull in the FX rate, you then create a measure that uses both the transaction’s date (from the Date Table) and the currency (from Data Tags) to filter the FX Table—for example, with a CALCULATE that applies TREATAS or a relationship with USERELATIONSHIP. This structure ensures that when you select a data output, Power BI can find the right FX rate by matching both the correct date and the correct currency.

     

6 Replies

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi CM_Mills ,

    Thank you Poojara_D12 , danextian , johnt75  for your inputs.

    I hope the information provided is helpful. I wanted to check whether you were able to resolve the issue with the provided solutions. Please let us know if you need any further assistance.

    Thank you.

  • I would combine the data table and the data tags table so that there is only 1 table with both the value and the currency. This is likely to make your measures much simpler and more efficient.

    I would also suggest reading https://www.daxpatterns.com/currency-conversion/ which goes into quite a bit of detail and has several code snippets which you may be able to adapt to your model.

  • Hi CM_Mills 

     

    Try the following measure:

    Converted to FX = 
    SUMX (
        ADDCOLUMNS (
            SUMMARIZECOLUMNS (
                Dates[Date],
                DataTags[Data Currency],
                "@lc", CALCULATE ( SUM ( 'DataTable'[LC] ) )
            ),
            "@converted",
                DIVIDE (
                    [@lc],
                    LOOKUPVALUE (
                        FXRates[FX Rate],
                        FXRates[Dates], [Date],
                        FXRates[FX Currency (From)], [Data Currency]
                    )
                )
        ),
        [@converted]
    )
    

    Please see the attached pbix.

  • Hi CM_Mills 

    In your model, the challenge comes from the fact that your FX table has both date and currency, while your main Data Table has date but the currency information only exists in the separate Data Tags table. Since the Data Tags table doesn’t contain dates, you can’t directly relate it to the FX table. The correct approach is to bridge these relationships: link the Data Table to the Date Table on the Date field, link the FX Table to the Date Table on Dates, and link the Data Table to Data Tags on the Unique Identifier. This way, your Data Table provides both the transaction date and, via the Data Tags, the relevant currency. To pull in the FX rate, you then create a measure that uses both the transaction’s date (from the Date Table) and the currency (from Data Tags) to filter the FX Table—for example, with a CALCULATE that applies TREATAS or a relationship with USERELATIONSHIP. This structure ensures that when you select a data output, Power BI can find the right FX rate by matching both the correct date and the correct currency.

     

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi CM_Mills ,

    We’d like to follow up regarding the recent concern. Kindly confirm whether the issue has been resolved, or if further assistance is still required. We are available to support you and are committed to helping you reach a resolution.

    Best Regards,
    Chaithra E.

  • v-echaithra's avatar
    v-echaithra
    Icon for Community Support rankCommunity Support

    Hi CM_Mills ,

    May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.

    Thank you.