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
o59393
Post Prodigy
Post Prodigy

Lookupvalue not working between 2 tables

Hi all

 

I am doing a lookup calcualted column, but doesn't work

 

Basically I have a table called 'Master Plant & Product' that has to xlooup its values on another table called 'SKU by line - Official'.

 

The IF statement I use is very simple:

 

IF value in column Merged Plant & Product of 'Master Plant & Product' table is found in column Merged Plant & Product of 'SKU by line - Official' table, then return an "Exists" else "Doesn't exist".

 

The example above is explained in this excel: https://1drv.ms/x/s!ApgeWwGTKtFdh2c9PC00KsBrHMrF?e=AMkZgI

 

I am trying to replicate that with a lookupvalue but gives me an error:

 

o59393_0-1633564841037.png

 

 

 

The relationship is a 1:M

 

o59393_1-1633564886101.png

 

 

Can you please advise how to make it work?

 

Thanks.

1 ACCEPTED SOLUTION

Try this instead...

IF('Master Plant & Product'[Merged Plant & Product] IN DISTINCT('SKU by line - Official'[Merged Plant & Product]), 1,0)

 

I may have typo'd your column names so double check those.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

11 REPLIES 11
o59393
Post Prodigy
Post Prodigy

Hi @KNP 

 

The purpose is to have an alert system when user misses adding the correct data. Long story short I summarized it in that excel to not include all the model and sensible data.

 

Can we have it in dax calculated column? 

Thanks !!

I think the RELATED function would be more useful given you already have a relationship setup.

Checkout this link.

https://stackoverflow.com/questions/67783229/check-if-value-is-in-another-table-and-add-columns-in-p... 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Hi @KNP 

 

Look at the error after using related:

o59393_1-1633571949628.png

 

 

 

Strangely I do have a relationship.

 

Any idea?

 

Thanks.

Try this instead...

IF('Master Plant & Product'[Merged Plant & Product] IN DISTINCT('SKU by line - Official'[Merged Plant & Product]), 1,0)

 

I may have typo'd your column names so double check those.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Wow @KNP 

 

It worked! so the distinct in your dax basically converted the duplicated values to unique ones correct?

 

Thank you so much 🙂

It just gets the unique values of that column from the SKU table to compare with the Master table. So not to compare every row. 

At least, that's how I understand it to work.

 

Glad I could help, especially since my DAX knowledge is a work in progress. 😁

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Thank you so much @KNP 

 

I guess the duplicate values on the SKU table were making noise and couldn't return the value.

 

Thanks!

Just did some testing/reading.

Looks like the RELATED (at least in this scenario) only works on the table on the 'many' side of the relationship. So in your case, the column would need to be added to the SKU table I believe.

 

There will be a better way. Going to do some more investigation.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Can you double check the column name in the SKU table?

It isn't recognising it for some reason.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

If you need a DAX solution I'll leave it for someone better versed in DAX.

If you wanted Power Query I'd simply merge with appropiate joins to only keep existing/non-existing.

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x
KNP
Super User
Super User

As far as the report is concerned, what is the purpose of the 'Product Exists' column?

Would you be happy for a Power Query solution or does it need to be DAX?

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

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.