Forum Discussion

mlee's avatar
mlee
Frequent Visitor
7 years ago

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

    • mlee's avatar
      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

       

       

  • v-juanli-msft's avatar
    v-juanli-msft
    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

    • mlee's avatar
      mlee
      Frequent Visitor

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