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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
Super User
Super User

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
Super User
Super User

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.  

 

 

 

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.