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

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

Reply
georgec96
Helper II
Helper II

one to many relationship RELATED () function

Hi everyone,

 

I have two tables with and trying to get the related column from the many side of the relationship to the one side, however the function RELATED() does not work.

 

I have a  table called open_orders and one table called open_lines which contains duplicate values, I would like to get the status column from the open_lines and bring it to the open_orders table.

 

georgec96_1-1660116869049.png

georgec96_2-1660116908007.png

 

 

 

Could anyone explain me how could i achieve that?

 

Thank you.

1 ACCEPTED SOLUTION

You would need a column containing unique identifiers in case of multiple entries on the same date. If there isn't such a column in the data already, you could add an index column in Power Query and use that.

Then you can create a column like

Status =
SELECTCOLUMNS (
    TOPN (
        1,
        RELATEDTABLE ( order_lines ),
        order_lines[status date], DESC,
        order_lines[unique ID], DESC
    ),
    "@val", order_lines[Status]
)

View solution in original post

6 REPLIES 6
johnt75
Super User
Super User

RELATED works from the many side to the one side, you need RELATEDTABLE. You could create a column like

Status = MINX( RELATEDTABLE(open_lines), open_lines[status])

@johnt75 

 

Thank you, that worked perfectly. Would you be able to explain how does it work though? If there is duplicate values which one is it retrieving?

It will get the first one in alphabetical order, that is what the MIN is doing. From the screenshots it looked like all entries for the same order had the same status, if that's not the case then you could look to combine SELECTCOLUMNS, TOPN and RELATEDTABLE to sort the related entries by whichever columns were relevant

@johnt75  Would it be possible to retrieve the value from the status column based on another date column?

 

Basically I want to get the latest status based on the date column

You would need a column containing unique identifiers in case of multiple entries on the same date. If there isn't such a column in the data already, you could add an index column in Power Query and use that.

Then you can create a column like

Status =
SELECTCOLUMNS (
    TOPN (
        1,
        RELATEDTABLE ( order_lines ),
        order_lines[status date], DESC,
        order_lines[unique ID], DESC
    ),
    "@val", order_lines[Status]
)

@johnt75 Thank you

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.