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

How do I retrieve a record from another table if it is contained in a value in the current table?

I am trying to use the Query Editor to check if a value in Table1 contains any value in Table2 (EarningTypes) and then return the matching value when found. Here is the custom M query code I am using:

 

if List.ContainsAny(Text.Split([Trim_null]," "),EarningTypes[Type]) = true then EarningTypes[Type] else ""

 

It returns a result, but the result appears as a "list" item instead of an actual value. 


Anyone know how I can convert the list record into an actual table value alongside of the original data or simply retrieve the matching record in a manner similar to a Merge Query?

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this custom column

 

=Text.Combine(List.Intersect({Text.Split([Trim_null]," "),EarningTypes[Type]})," ")
Anonymous
Not applicable

That worked perfectly. Unfortunately, I realized after I tried your solution that I was actually wanting to do something slightly different. Currently, my formula splits a string at each occurence of the delimiter. What I actually need is to simply see if a string contains any text that appears as a value in another table and return the matching text.

 

I have tried modifying this on my own using functions such as List.ContainsAny, but I cannot get it to work.

Hi @Anonymous 

 

Could you Copy paste a small dataset with expected results?

Anonymous
Not applicable

@Zubair_Muhammad ,

 

I appreciate all your help and hope the following gives you sufficient information.

 

This is the OriginalImport table:

 

CSV String
                      001 Category A    11.11    13.121     1,232.11       1,125.15     Type C      145.21       1,641.85 
      005 Category B        150    2.62       311.24         760.14       Type B        57.25         176.95 
                                                                                      W    Type A          27.00         981.00 

 

This is an example of Table1 from which I want to return a result if a match is found using:

 

EarnCodeCategoryJoined
001Category A001 Category A
005Category B005 Category B

 

This is an example of the Table2 from which I want to return a result if a match is found:

 

DeductCodeTypeJoined
WType AW Type A
 Type BType B
 Type CType C

 

This is the DesiredResult table:

 

CSV StringEarnCodeCategoryDeductCodeType
                      001 Category A    11.11    13.121     1,232.11       1,125.15     Type C      145.21       1,641.85 001Category A Type C
      005 Category B        150    2.62       311.24         760.14       Type B        57.25         176.95 005Category B Type B
                                                                                      W    Type A          27.00         981.00   WType A

 

The logic I have in mind to populate the columns in the DesiredResult table looks something like this:

 

EarnCode: IF [CSV String] contains a value in Table1[Joined], then return matching Table1[EarnCode]

 

Category: IF [CSV String] contains a value in Table1[Joined], then return matching Table1[Category]

 

DeductCode: IF [CSV String]contains a value in Table2[Joined], then return matching Table2[DeductCode]

 

Type: IF [CSV String] contains a value in Table2[Joined], then return matching Table2[Type]

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.