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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
BijuDev
New Member

How to use "if" & lookup function together in a condition in power query/ power bi

Hello Team

Need support on how to use IF and Vlookup functions  together in power query or power BI. Example I have two data set like below.
I need to first look for column A, if column is not blank, vlookup the value in  second Data Set 2, retun the Division , else (if A column is blank) lookup the value in colum B ( ie PC column) , return the Division from Data Set 2 ( colum B )

DataSet 1

CCPCAmt
CC5900 10
 PC690245
CC5901 60
   

 

Data Set 2 ( Master)

CC/PCDivision
CC5900Sales
CC5901Marketing
PC6901Sales
PC6902Marketing

 

Output

CCPCAmtDivision
CC5900 10Sales
 PC690245Marketing
CC5901 60Sales
    
1 ACCEPTED SOLUTION
StrategicSavvy
Resolver II
Resolver II

hi @BijuDev ,

 

you can also consider using power query to do this. Here are the steps:

1. go to your Data Set 1 and make sure you have nulls in both column CC / PC

you can use replace values to null them

StrategicSavvy_0-1710081370796.png

 

2. add new column in your dataset 1 using double question marks (coalesce operator)

StrategicSavvy_1-1710081439397.png

you will get this column :

StrategicSavvy_2-1710081469197.png

3. merge your dataset 1 with dataset 2

 

StrategicSavvy_3-1710081508685.png

 

4. expand your table and select division column 

StrategicSavvy_4-1710081547439.png

 

 

 

PBIX 

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: www.linkedin.com/in/lukasz-kozdron 

 

View solution in original post

4 REPLIES 4
BijuDev
New Member

Thanks Luca, I created a calculated column on Data Set 1 using above method. However,  I need one more column in Data Set 1 which should retun corresponding Divison Name from Data set 2 ( look up array)

You have to connect the two table and create the measure to do the calculation.



Luca D'Elicio

LinkedIn Profile
StrategicSavvy
Resolver II
Resolver II

hi @BijuDev ,

 

you can also consider using power query to do this. Here are the steps:

1. go to your Data Set 1 and make sure you have nulls in both column CC / PC

you can use replace values to null them

StrategicSavvy_0-1710081370796.png

 

2. add new column in your dataset 1 using double question marks (coalesce operator)

StrategicSavvy_1-1710081439397.png

you will get this column :

StrategicSavvy_2-1710081469197.png

3. merge your dataset 1 with dataset 2

 

StrategicSavvy_3-1710081508685.png

 

4. expand your table and select division column 

StrategicSavvy_4-1710081547439.png

 

 

 

PBIX 

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: www.linkedin.com/in/lukasz-kozdron 

 

lucadelicio
Super User
Super User

Hi,
try to craete the same CC/PC Column also in the dataset 1.
Add calculated column:
CCPC =
IF(ISBLANK(CC), PC, CC)
Then you can connect the dataset1 with dataset2 on CC/PC Column and do the calculation with the measure that you want.
Mark as a solution my answer if i help you.
Thank you.



Luca D'Elicio

LinkedIn Profile

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.