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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Les111
Resolver I
Resolver I

Trying to lookup value in table that has duplicates

I'm trying to lookup if a value exists in another table. This will determine whether to show/hide rows in the output based on whether there is a match.  

 

This is my data table:

GroupAndMetricID
InpatientM61
InpatientM61
InpatientM61
CommunityM61
CommunityM61
InpatientM59
CommunityM59

 

And my lookup table:

GroupAndMetric
InpatientM61
CommunityM61
InpatientM59
CommunityM59

 

So for each row in the data table I want to know if there is a matching value in the lookup table. I've tried these dax expressions, but get the errror 'a single value for column 'GroupAndMetricID' in table 'DataTable' cannot be determined...'

 

MatchColumn = IF(CONTAINS (DataTable, DataTable[GroupAndMetricID], LookupTable[GroupAndMetric] ),1,0)

 

MatchColumn = IF(LookupTable[GroupAndMetric] IN SELECTCOLUMNS ( RELATEDTABLE ( 'DataTable' ), DataTable[GroupAndMetricID]),1,0)

 

I have tried using measures and columns for this but still the same error. Can anyone suggest a solution?

Thanks

2 ACCEPTED SOLUTIONS
ArwaAldoud
Responsive Resident
Responsive Resident

You can solve this issue using LOOKUPVALUE or RELATED in DAX, or by creating a calculated column with EXISTS/LOOKUP functions.

Using LOOKUPVALUE calculated column in your DataTable:

MatchColumn = IF(
NOT(ISBLANK(LOOKUPVALUE(LookupTable[GroupAndMetric], LookupTable[GroupAndMetric], DataTable[GroupAndMetricID]))),
1, 0
)

If you have a relationship between the two tables, you can use Related:

MatchColumn = IF(NOT(ISBLANK(RELATED(LookupTable[GroupAndMetric]))), 1, 0)

this works only if LookupTable is related to DataTable on GroupAndMetricID.


- Ensure LookupTable has unique values in GroupAndMetric (no duplicates).
- If there’s no direct relationship, use LOOKUPVALUE instead of RELATED.

Try these solutions and let me know if you need further clarification

If this response was helpful, please accept it as a solution and give kudos to support other community members

View solution in original post

Poojara_D12
Super User
Super User

Hi @Les111 

I have attached a document that has few ideas about this issue, please check.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

View solution in original post

7 REPLIES 7
Poojara_D12
Super User
Super User

Hi @Les111 

I have attached a document that has few ideas about this issue, please check.

 

Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos"

Kind Regards,
Poojara - Proud to be a Super User
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS

Thank you Poojara. 

ArwaAldoud
Responsive Resident
Responsive Resident

You can solve this issue using LOOKUPVALUE or RELATED in DAX, or by creating a calculated column with EXISTS/LOOKUP functions.

Using LOOKUPVALUE calculated column in your DataTable:

MatchColumn = IF(
NOT(ISBLANK(LOOKUPVALUE(LookupTable[GroupAndMetric], LookupTable[GroupAndMetric], DataTable[GroupAndMetricID]))),
1, 0
)

If you have a relationship between the two tables, you can use Related:

MatchColumn = IF(NOT(ISBLANK(RELATED(LookupTable[GroupAndMetric]))), 1, 0)

this works only if LookupTable is related to DataTable on GroupAndMetricID.


- Ensure LookupTable has unique values in GroupAndMetric (no duplicates).
- If there’s no direct relationship, use LOOKUPVALUE instead of RELATED.

Try these solutions and let me know if you need further clarification

If this response was helpful, please accept it as a solution and give kudos to support other community members

Thank you Arwa!

 

Both these solutions work, but I'm using RELATED rather than LOOKUPVALUE as my tables are related and I'm assuming this is more efficient.  

 

 

 

ArwaAldoud
Responsive Resident
Responsive Resident

You're welcome @Les111 

Yes, RELATED is more efficient when tables are already connected. Glad it worked

lbendlin
Super User
Super User

Please confirm if this is indeed for Report Server, or for a semantic model in the Power BI Service?

Yes it's report server.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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