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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
nikhil_chauhan
Regular Visitor

using range lookup in power bi

Hi i wanted to know ,, how could i use lookup in power bi

 

eg

if sheet1 in excel contained

column A                 COLUMN B          COLUMN C

roll number from     roll number to       CLASS   

1                                20                           A

20                               40                        B

40                                60                       C

 

and if wanted to know which roll no is in which class i would simple use lookup(3,a1:a30,c1:c30)

and i would get the desired answer

 

how do i replicate the same in power bi

 

thanks

 

pn, i have the sheet with rolls nos and class

and another sheet containg various different roll no ,, where i should i get the class 

 

thank you

 

 

 

1 ACCEPTED SOLUTION
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @nikhil_chauhan,

 

In Power BI, we could use LOOKUPVALUE Function (DAX) to match the value.

 

Assuming that you have two tables like below.

Untitled.png

By my test, you could create a calculated column with the formula below.

 

Column =
LOOKUPVALUE ( T1[CLASS ], T1[roll number from], 'T2'[Roll NO] )

Then you will match the CLASS value in T1.

 

Capture.PNG

 

Please note that you should change the Roll No data type from whole number to text, because lookupvalue does not support comparing values of type text with values of type Integer. 

 

In addition, you could have a reference of this article.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @nikhil_chauhan,

 

In Power BI, we could use LOOKUPVALUE Function (DAX) to match the value.

 

Assuming that you have two tables like below.

Untitled.png

By my test, you could create a calculated column with the formula below.

 

Column =
LOOKUPVALUE ( T1[CLASS ], T1[roll number from], 'T2'[Roll NO] )

Then you will match the CLASS value in T1.

 

Capture.PNG

 

Please note that you should change the Roll No data type from whole number to text, because lookupvalue does not support comparing values of type text with values of type Integer. 

 

In addition, you could have a reference of this article.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi

 

It does not work as lookupvalue is based on equality. In this case we need to match a value and a range

For example: 30 should return B

hey @v-piga-msft

 

thanks a lot,,, that solved my problem

Hi @nikhil_chauhan,

 

It is glad that we can help. Only thing that you'll have to notice, just always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

The DAX lookup function does not seem to work for a lower and higher range as specified in the solution. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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