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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DK_m
Frequent Visitor

How to do If condition inside a Xlookup in power query

Hello,

 

I have two tables, where i need to create a custom column in table1 with Xlookup and if condition as below in power query.

Any suggestion is appreciated!

 

XLOOKUP(Table1[Acct],IF(Table1[Code]="10",Table2[ID],Table2[Reg]),Table2[Result],"",0) - as excel formula

 

@amitchandak @Greg_Deckler any idea ?

 

PFB, example 

DK_m_0-1679057747072.png

 

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

3 REPLIES 3
Ahmedx
Super User
Super User

Yes, you can do it in power query
For it
watch my video here
https://1drv.ms/v/s!AiUZ0Ws7G26RhkVJy1BzMCewswHT?e=IhiBz9
Sample PBIX file attached
https://1drv.ms/u/s!AiUZ0Ws7G26RhkSmF2LtunIY-yJ1?e=wcPPjd

Ahmedx
Super User
Super User

1) creat new tabl

 

Table = ALLSELECTED('Table_1'[Acct],Table_1[Code])
or 

Newtable = VALUES(Table_1)

 

1.png

 

2) add column

 

Column = 
IF([Code]=10, CALCULATE(MAX('Table_2'[Result]),FILTER(ALL(Table_2),'Table_2'[ID]=[Acct])),
CALCULATE(MAX('Table_2'[Result]),FILTER(ALL(Table_2),'Table_2'[Reg]=[Acct]))
)

 

2.png

DK_m
Frequent Visitor

is there any possible way in power query itself ?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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