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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
InsightSeeker
Helper III
Helper III

Creating a Calculated Column Between Two Unrelated Tables

 

Hi everyone,

 

I have two unrelated tables in my Power BI model, and I need help creating a calculated column in Table 1. The logic for the calculated column is as follows:

  • If Table1[from_currency_code] matches Table2[to_currency_code]
  • AND Table1[currency_code] is "AED"
  • AND Table1[active_status] is "A",

    Then return the value of Table1[conversion_rate] else return 1


    Here are the details of my tables:

    Table 1

    from_currency_code to_currency_code active_status conversion_rate
    HKDHKDI1
    AUDHKDA2.45
    BHDHKDA9.76729
    CHFHKDA4.25
    EURHKDA4
    GBPHKDA4.8
    KWDHKDA11.98
    OMRHKDA9.539
    QARHKDA1.00893
    SARHKDA0.97933
    USDHKDA3.67

    Table 2

    currency_code
    HKD
    AUD
    BHD
    CHF
    EUR
    GBP
    KWD
    OMR
    QAR
    SAR
    USD

    I would appreciate guidance on the best way to write the DAX formula for this calculated column since the tables are unrelated.

    Thanks in advance! 😊

2 ACCEPTED SOLUTIONS
danextian
Super User
Super User

Hi @InsightSeeker 

 

Try this:

Test = 
VAR _match =
    NOT (
        ISBLANK (
            LOOKUPVALUE (
                Table2[currency_code],
                Table2[currency_code], Table1[from currency]
            )
        )
    )
RETURN
    IF (
        _match
            && Table1[currency] = "AED"
            && Table1[active status] = "A",
        Table1[conversion rate],
        1
    )

Please take note though that as per your sample data, all rows return 1.

danextian_0-1734346599995.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

Hi @InsightSeeker ,

Thank you for clarify me, i just updated the DAX:

Calculated Column = 
IF(
    "AED" IN DISTINCT(
        SELECTCOLUMNS(
            FILTER(
                Table1, 
                Table1[from_currency_code] = Table2[currency_code] &&
                Table1[active_status] = "A"
            ), 
            "Currency", Table1[currency_code]
        )
    ),
    MAXX(
        FILTER(
            Table1, 
            Table1[from_currency_code] = Table2[currency_code] &&
            Table1[active_status] = "A"
        ), 
        Table1[conversion_rate]
    ),
    1
)

View solution in original post

8 REPLIES 8
Kedar_Pande
Super User
Super User

@InsightSeeker 

Calculated Column =
IF(
Table1[active_status] = "A"
&& Table1[to_currency_code] = "HKD"
&& LOOKUPVALUE(Table2[currency_code], Table2[currency_code], Table1[from_currency_code], "") = "AED",
Table1[conversion_rate],
1
)

This formula works without needing to create a relationship between the tables and evaluates the logic for each row in Table 1.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Hi @Kedar_Pande  - I need to write the DAX formula for this calculated column in Table 2, considering that the two tables are unrelated. 

Bibiano_Geraldo
Super User
Super User

Hi @InsightSeeker ,
you can use the LOOKUPVALUE function to check the condition between the two tables, even though they are unrelated. Here’s how you can write the DAX formula:

Calculated Column = 
IF(
    Table1[currency_code] = "AED" &&
    Table1[active_status] = "A" &&
    NOT(ISBLANK(
        LOOKUPVALUE(
            Table2[currency_code],
            Table2[currency_code], Table1[from_currency_code]
        )
    )),
    Table1[conversion_rate],
    1
)

Hi @Bibiano_Geraldo  - I need to write the DAX formula for this calculated column in Table 2, considering that the two tables are unrelated. I have tried your suggestion but it is not giving me the desired results.

The key point to note is that the result will not be 1 for all rows in Table 2, as each currency has a different conversion rate based on the data in Table 1.

 

 

Hi @InsightSeeker ,

Thank you for clarify me, i just updated the DAX:

Calculated Column = 
IF(
    "AED" IN DISTINCT(
        SELECTCOLUMNS(
            FILTER(
                Table1, 
                Table1[from_currency_code] = Table2[currency_code] &&
                Table1[active_status] = "A"
            ), 
            "Currency", Table1[currency_code]
        )
    ),
    MAXX(
        FILTER(
            Table1, 
            Table1[from_currency_code] = Table2[currency_code] &&
            Table1[active_status] = "A"
        ), 
        Table1[conversion_rate]
    ),
    1
)
danextian
Super User
Super User

Hi @InsightSeeker 

 

Try this:

Test = 
VAR _match =
    NOT (
        ISBLANK (
            LOOKUPVALUE (
                Table2[currency_code],
                Table2[currency_code], Table1[from currency]
            )
        )
    )
RETURN
    IF (
        _match
            && Table1[currency] = "AED"
            && Table1[active status] = "A",
        Table1[conversion rate],
        1
    )

Please take note though that as per your sample data, all rows return 1.

danextian_0-1734346599995.png

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Hi @danextian - I need to write the DAX formula for this calculated column in Table 2, considering that the two tables are unrelated. The key point to note is that the result will not be 1 for all rows in Table 2, as each currency has a different conversion rate based on the data in Table 1.

The question now which row from table1 should table2 pick given that there can be more than one result? Calculated columns cannot return two rows.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.