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
abbynie08
Microsoft Employee
Microsoft Employee

How to use lookupvalue function for PBI direct query/dual mode

Hi all, 

 

The lookupvalue function does not show in PBI under direct query mode/dual mode. I have been seraching on the forum and did not get answers. I would really appreciate if you can help me with that. So I want to get the Required_2 column by looking up Role_2 column in Role Column and return the required number in the required_2 table. Normally, I can use the lookupvalue function. But under direct query/dual mode, the function does not work.  Some people have suggested changing the settings under file=>options=>direct query, but there is no options to allow the function to work.

 

Thank you!

 

CustomerRoleRequiredRole_2Required_2
1Inside Sales1Sales4
1Inside Tech2Tech5
1Inside Manager3Manager6
1Sales4Sales4
1Tech5Tech 5
1Manager6Manager6
1VP7VP7

 

 

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @abbynie08 

 

In DirectQuery, calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. You may create a measure as below,which is the same effect as lookupvalue function.

 

Measure = 
//LOOKUPVALUE('Table'[Required_2],'Table'[Role_2],SELECTEDVALUE('Table'[Role]))
CALCULATE(
    VALUES('Table'[Required_2]),
    FILTER(
        'Table',
        'Table'[Role_2] = SELECTEDVALUE('Table'[Role])
    )
)

 

 

Result:

c1.png

 

Best Regards

Allan

 

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-alq-msft
Community Support
Community Support

Hi, @abbynie08 

 

If you take the answer of someone, please mark it as the solution to help the other members who have same problems find it more quickly. If not, let me know and I'll try to help you further. Thanks.

 

Best Regards

Allan

v-alq-msft
Community Support
Community Support

Hi, @abbynie08 

 

In DirectQuery, calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. You may create a measure as below,which is the same effect as lookupvalue function.

 

Measure = 
//LOOKUPVALUE('Table'[Required_2],'Table'[Role_2],SELECTEDVALUE('Table'[Role]))
CALCULATE(
    VALUES('Table'[Required_2]),
    FILTER(
        'Table',
        'Table'[Role_2] = SELECTEDVALUE('Table'[Role])
    )
)

 

 

Result:

c1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

olimilo
Continued Contributor
Continued Contributor

Is this not possible to do as a calculated column? Especially when there's a need to filter the data

Ashish_Mathur
Super User
Super User

Hi,

Does this calculated column formula work?

=CALCULATE(SUM(Data[Required]),FILTER(Data,Data[Role]=EARLIER(Data[Role_2])))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@abbynie08 seems like you are referring two different tables , can you put sample data of each table and it is bit confusing what you have shown below. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.