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
Anonymous
Not applicable

How to do a LOOKUPVALUE with FILTER?

Hello,

I have two tables that follow this structure:
table1

ID   Dimension  Validation  
1AAA12334
2BBB23434
3CCCxxx
4DDD45652
5EEExxx



table2

IDName  
1Kim
2John
3Alec
4Phill
5Noah

 

The tables are joined by the ID column. I want to use a LOOKUPVALUE on table2 to search the value from the Dimension column on table1, but I want this LOOKUPVALUE to be done only on rows where the column Validation <> "xxx" (is different from "xxx").

My expected result would be like this:

IDName  Dimension  
1KimAAA
2JohnBBB
3Alec 
4PhillDDD
5Noah 

 

How can I do this?

1 ACCEPTED SOLUTION

Hi @Anonymous ,

Try the following formula:

Dimension = 
CALCULATE(
    MAX(Table1[Dimension]),
    FILTER(
        Table1,
        Table1[Validation] <> "xxx"
        &&Table1[ID]=Table2[ID]
    )
)

v-kkf-msft_0-1616989749606.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

3 REPLIES 3
selimovd
Super User
Super User

Hey @Anonymous ,

 

if you want that as a measure the code like this would work:

Dimension Value = CALCULATE( MAX( table1[Dimension  ] ), table1[Validation] <> "xxx" )

 

If you want that as a calculated column the following code should work:

Dimension Value Column = IF( RELATED( table1[Validation] ) <> "xxx", RELATED( table1[Dimension] ) )

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 
Anonymous
Not applicable

Hello, @selimovd  thanks for the response!

I want to create a calculated column, but when I try to use this code that you created, the RELATED function does not give me any option to be searched in the table1, as if I had not even linked. But when I make this same calculated column in table1, the RELATED function brings me all the values ​​in table2.

The link for my table1 and table2 are like:


table1   * ----------1  table2

but the Dimension column of table1 always shows only two possible values for the same ID: the actual value that I want to get and the value "xxx".
For example: for the column in table1 with ID=1 

ID   Dimension  Validation  
1AAA12334
1AAA12334
1BBBxxx
1AAA12334
1CCCxxx


so, the RELATED function in table2 should bring me the Dimension = AAA


Hi @Anonymous ,

Try the following formula:

Dimension = 
CALCULATE(
    MAX(Table1[Dimension]),
    FILTER(
        Table1,
        Table1[Validation] <> "xxx"
        &&Table1[ID]=Table2[ID]
    )
)

v-kkf-msft_0-1616989749606.png

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.

Best Regards,
Winniz

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

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.