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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MAruna
Frequent Visitor

Lookup with logic on multiple rows

I Have two different tables

 

Table 1:-

I'd            I'd Type          Region

123.          Legacy
300           EmpId
145            CanID
301            EmpId
350            EmpId
150            CanId

 

Table 2:

EmpId          CanId             Region
300                123               EA
301                145               NORTH
350                150                EAST

 

Logic :-  >= 300 EmpId
                <300  CanId

Q)Need to get Region In table 1 based on table2
can any one tell me the Dax function to get this

Thankyou in advance.

 

 

1 ACCEPTED SOLUTION

@MAruna 
Please try

=
MAXX (
    FILTER (
        UNION (
            SELECTCOLUMNS ( Table2, "@ID", Table2[Empid], "@Region", Table2[Region] ),
            SELECTCOLUMNS ( Table2, "@ID", Table2[Canid], "@Region", Table2[Region] )
        ),
        [@ID] = Table1[id]
            && [@ID] <> BLANK ()
    ),
    [@Region]
)

View solution in original post

5 REPLIES 5
tamerj1
Super User
Super User

Hi @MAruna 

assuming no relationship between the two tables 

=
MAXX (
FILTER (
UNION (
SELECTCOLUMNS ( Table2, "@ID", Table2[Empid], "@Region", Table2[Region] ),
SELECTCOLUMNS ( Table2, "@ID", Table2[Canid], "@Region", Table2[Region] )
),
[@ID] = Table1[id]
),
[@Region]
)

Thank you @tamerj,

In ID's field some rows are null values,by using your dax formula im getting region for null aslo.

Could you please help me to get rid off from null values 

@MAruna 
Please try

=
MAXX (
    FILTER (
        UNION (
            SELECTCOLUMNS ( Table2, "@ID", Table2[Empid], "@Region", Table2[Region] ),
            SELECTCOLUMNS ( Table2, "@ID", Table2[Canid], "@Region", Table2[Region] )
        ),
        [@ID] = Table1[id]
            && [@ID] <> BLANK ()
    ),
    [@Region]
)
MAruna
Frequent Visitor

Based on ID's I am taking

FreemanZ
Super User
Super User

hi @MAruna 

how are the two tables related?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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