Forum Discussion
SEARCH function using another column to find value in text string
Hello,
I am trying to use a column name "Account Context" that is a Text string field (ex. ADJ:191907 SPORTS INC.) which contains some random integers as well as a customer name.
I want to be able to search the "Account Context" column and match it up with a Customer Name that is within my "Customer Name" column.
I have tried this a few different ways and cannot seem to get the DAX formula that can actually SEARCH the "Account Context" field and get a result.
any help would be great!!
- Anonymous2 years ago
Hi nmoriello ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
Customer table:
Table:
(2)We can create a new table.
Table 2 = var tmp=CROSSJOIN('Table',Customer) var tmp1=ADDCOLUMNS(tmp,"Flag",CONTAINSSTRINGEXACT([TranGLC_GLAcctContext],[Customer Name])) var tmp2=FILTER(tmp1,[Flag]=TRUE()) var tmp3=SELECTCOLUMNS(tmp2,"Customer Name",[Customer Name]) return tmp3(3)Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
9 Replies
- nmorielloFrequent Visitor
What i am trying to end up with is being able to use a DAX function (ive tried, CONTAINSSTRING, SEARCH, FIND) to look at my "Account Context" column and be able to idenify the matching customer name that i see within my "Customer Name" column.
The issue i am currently having is that using any of those functions (the way I know how) isnt giving me any results. Here is one DAX forumula I have tried:
MATCHING COLUMN = IF( SEARCH('FINAL Sales & Cost'[Customer Name], 'FINAL Sales & Cost'[TranGLC_GLAcctContext], 1, 0) > 0, "Match", "No Match" )
I am getting no matches for this.
- AnonymousNot applicable
Hi nmoriello ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
(2) We can create a calculated column.
Column = IF(CONTAINSSTRINGEXACT([TranGLC_GLAcctContext],[Customer Name])=TRUE(),"Match","No Match")(3) Then the result is as follows.
If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- nmorielloFrequent Visitor
Hi Anonymous
This Match would work fine but my issue is that every line is different. For example, below are some examples of what i am seeing in my TranGLC_GLAcctContext column, the highlighted portion are customer names that I want to extract from that field and then match up with a corresponding customer name on my "Customer" table. For example that first line would extract the "GUNARAMA WHOLESALE, INC" then match it up to my "Customer" table and spit out a column with any matching customer names.
Within excel I was able to do this by using this logic:
INDEX('Customer'!$A$2:$A$2020,MATCH(TRUE,ISNUMBER(SEARCH('Customer'!$A$2:$A$2020,Table1[TranGLC_GLAcctContext]])),0))
I would like to basically recreate this logic with a DAX measure.
- AnonymousNot applicable
Hi nmoriello ,
According to your description, here are my steps you can follow as a solution.
(1) This is my test data.
Customer table:
Table:
(2)We can create a new table.
Table 2 = var tmp=CROSSJOIN('Table',Customer) var tmp1=ADDCOLUMNS(tmp,"Flag",CONTAINSSTRINGEXACT([TranGLC_GLAcctContext],[Customer Name])) var tmp2=FILTER(tmp1,[Flag]=TRUE()) var tmp3=SELECTCOLUMNS(tmp2,"Customer Name",[Customer Name]) return tmp3(3)Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.