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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mlee
Frequent Visitor

Using a column of values with CONTAINSSTRING

I have the following DAX expression for a new calculated table:

 

FILTER(
'Grid Data',
AND(
RELATED('Model'[Id]) = 68,
OR(
CONTAINSSTRING('Grid Data'[Family Name],"(E)"),
CONTAINSSTRING('Grid Data'[Family Name],"built")
)
)
 
With the hardcoded values the table is generated just fine.
 
However, instead of hardcoding I want the expression to reference the following table instead:
 
 
Search Term Table
ModelIdSearch terms
68built
68(E)
69Rail
69missing
69generic
 
What I'd like to do is for each Model ID use the associated search terms against the Family Name column using CONTAINSSTRING. I was able to get a column of all the distinct search terms for a particular model but when I try using that column in CONTAINSSTRING it fails since the function is only expecting a single value in the find text parameter.
 
Does anyone know if this is doable? 
 
Thanks,
 
Mike
8 REPLIES 8
v-juanli-msft
Community Support
Community Support

Hi @mlee 

Is your data large?

I think i would add some columns or a new table which woild increase the data size and reduce the performance.

 

Best Regards
Maggie

The data could be large. It depends on how much filtering I perform upstream.

parry2k
Super User
Super User

@mlee it is possible, can you share data model? What are you trying to achieve? Do you want to create new table or some sort of measure. It is not clear what end result you are looking for?

 

Read this post to get your answer quickly.

https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

mlee
Frequent Visitor

Sure thing @parry2k 

 

The 4 tables involved:

 

Grid Data

 

ModelVersionIDElement Name
100Built-in Bar
100Existing Wall2
100Existing Wall3
101Door Frame (E)
101Desk
101Generic Wall
102Built-in Bar
102Existing Wall2
102Carpeting

 

Model Version

 

IDModelID
10068
10168
10269

 

Model

ID
68
69

 

 

Search Term

 

ModelIdSearch terms
68built
68(E)
69Rail
69missing
69generic

 

Relationships

 

Model  Model Version

Id 1: * Model Id

 

Model Version   Grid Data

Id 1: * ModelVersionId

 

Model  Search Term  

Id 1: * Model Id

 

The DAX expression I'm needing is for a new Calculated Table.

 

The calculated table should be a subset of the Grid Data table. The DAX expression should filter based on the search terms for each model.

 

For example, for model 68 I have built and (E) for search terms. The expression should travel down to the grid data table and find all rows with that are associated with Model ID 68. In this case that corresponds to Model Version ID's of 100 and 101. Next the expression should look at all rows with Model Version ID 100 and 101 in Grid Data and look at the Family Name column and filter based on the search terms built and (E).  I'm using CONTAINSSTRING since I'm looking for partial text matches. For Model 68 two rows should be kept...the row with Built-in Wall and Door Frame(E).

 

Once the filtering is done for Model Id 68 the expression should move on to Model Id 69 and repeat the same steps.

 

This expression I wrote in my original post works if I hard code some values in. But I'm not sure how to make this Calculated Table work when filtering based on another table's columns.

 

Mike

 

 

Hi,

Please show the your final expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

The final output would be:

 

ModelVersionIDElement Name
100Built-in Bar
101Door Frame (E)
102Existing Wall 2

Hi @mlee 

For 69, it contains "Rail, missing, generic" , 

ModelId Search terms
68 built
68 (E)
69 Rail
69 missing
69 generic

 

69 corresponds to Model Version ID's of 102,

but the Element Name of 102 contains

"Built-in Bar,Existing Wall2, Carpeting",

we can't find any of "Rail, missing, generic" in "Built-in Bar,Existing Wall2, Carpeting"

why the final output is ?

ModelVersionID Element Name
100 Built-in Bar
101 Door Frame (E)
102 Existing Wall 2

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

You are correct @v-juanli-msft . I made a mistake when I pasted in the final output. 

 

The corrected final output would be:

 

ModelVersionIDElement Name
100Built-in Bar
101Door Frame (E)

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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