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

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

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors