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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
KristofferAJ
Helper III
Helper III

Related column between two tables

I have a small table (ORANGE) with a 1-to-many relationship to a very large dataset (APPLE), the connection point is "city"

 

I would like to establish a column in APPLE indicating if the city is present in ORANGE, with a statement of false or true depending if the city is present in both tables..

 

I have not access to the datamodel in the back so I need to handle this through inserting a column

 

KristofferAJ_0-1737384229497.png

 

Perhaps RELATED? LOOKUPVALUE? RELATEDTABLE?

1 ACCEPTED SOLUTION

Hi, @KristofferAJ 

Use the following expression to create a calculated table:

Table 2 = SUMMARIZE('APPLE','APPLE'[City],"ORANGE",[Measure])

vjianpengmsft_0-1737450811681.png

Recreate the relationship as follows:

vjianpengmsft_1-1737450857473.png

Since the countries in the ORANGE table do not necessarily include the countries in APPLE, blank values ​​will appear when it is put into the slicer:

vjianpengmsft_3-1737451100195.png

So set this column:

vjianpengmsft_2-1737450882011.png

 

 

Best Regards

Jianpeng Li

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

7 REPLIES 7
KristofferAJ
Helper III
Helper III

Hi! this looks very spot on, I was trying it but got an error saying that the column 'cannot be pushed to the remote data source and cannot be used in this sceanrio' - I suspect its because its a model which I dont have rights to make a column in?

Thank you Bibiano_Geraldo 

Hi, @KristofferAJ 

First, your APPLE table join mode is Directquery, and secondly your ORANGE is import. You have a one-to-many relationship for them.

I did run into the same problem as you when I created a calculated column in direct query mode using Super user's expression:

vjianpengmsft_0-1737427389027.png

To do this, I've created a measure as follows:

Measure = 
VAR _apple_table = SUMMARIZE(ALLSELECTED(APPLE),'APPLE'[City],"column",
    IF(ISBLANK(LOOKUPVALUE('Table'[ORANGE],'Table'[ORANGE],'APPLE'[City])),"FALSE","TRUE")
)
VAR _current_city = SELECTEDVALUE(APPLE[City])
RETURN MAXX(FILTER(_apple_table,'APPLE'[City] = _current_city),[column])

vjianpengmsft_1-1737427956433.png

It works correctly with your imported Table and Direct Query connection mode tables. 

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is great and works! - I can use it as part of a table, but not as legend or in a filter, suspect thats becasue its a measure?

Any way that this can be made into a column instead? - when I try it gives me the "circular dependency" error

Hi, @KristofferAJ 

If you still just want to create a calculated column in the APPLE table, you can try the following expression:

Column = 
VAR _table = {
    ("London"),
    ("Munich")
}
RETURN IF([City] IN _table,"TRUE","FALSE")

 

vjianpengmsft_4-1737452084459.png

vjianpengmsft_5-1737452104049.png

You need to structure the countries in your ORANGE table in _table with each bracket representing a row.

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi, @KristofferAJ 

Use the following expression to create a calculated table:

Table 2 = SUMMARIZE('APPLE','APPLE'[City],"ORANGE",[Measure])

vjianpengmsft_0-1737450811681.png

Recreate the relationship as follows:

vjianpengmsft_1-1737450857473.png

Since the countries in the ORANGE table do not necessarily include the countries in APPLE, blank values ​​will appear when it is put into the slicer:

vjianpengmsft_3-1737451100195.png

So set this column:

vjianpengmsft_2-1737450882011.png

 

 

Best Regards

Jianpeng Li

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Hi @KristofferAJ ,
The error you're encountering indicates that the data source you're working with is a DirectQuery model or resides in a database where you don't have the ability to modify or create calculated columns.

 

You can learn more about Limitations of DirectQuery in Power BI here

Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

Bibiano_Geraldo
Super User
Super User

Hi @KristofferAJ ,

You can use LOOKUPVALUE function to achieve your goal:
Go to the APPLE table in Power BI Desktop and use the following DAX formula for the new column:

CityExistsInOrange = 
IF(
    ISBLANK(
        LOOKUPVALUE(
            ORANGE[city], 
            ORANGE[city], 
            APPLE[city]
        )
    ), 
    FALSE, 
    TRUE
)
Is this post help you? Please consider to:

Accept as Solution!
Give a Kudo
Follow me on Linkedin

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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