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
Diana_Jardim100
Frequent Visitor

RELATED TABLE WITH CONDITION

Hello guys, 

 

I'm trying to crate a column with  information from another table.

I tried to do a lookup but I have some duplicates so it didn't work.

The condition is: 

IF the end date is blank , then keep blank, otherwise, bring the last information contained in the second table - column (ID_TERM_REASON) 

 

First  Table

Diana_Jardim100_3-1667392733231.png

Second table 

Diana_Jardim100_2-1667392702981.png

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Diana_Jardim100 
Please try

ID_TERM_REASON =
IF (
    NOT ISBLANK ( Table1[End Date] ),
    MAXX (
        TOPN ( 1, RELATEDTABLE ( Table2 ), Table2[Date] ),
        Table2[ID_TERM_REASON]
    )
)

View solution in original post

2 REPLIES 2
Diana_Jardim100
Frequent Visitor

Many thanks.

It was exactly what I needed. 

 

tamerj1
Super User
Super User

Hi @Diana_Jardim100 
Please try

ID_TERM_REASON =
IF (
    NOT ISBLANK ( Table1[End Date] ),
    MAXX (
        TOPN ( 1, RELATEDTABLE ( Table2 ), Table2[Date] ),
        Table2[ID_TERM_REASON]
    )
)

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.