Forum Discussion
Compare text string between two tables (Not exact)
- Anonymous3 years ago
Hi TIGER8855 ,
You can create a calculated column as below in 'Table 1', please find the details in the attachment.
Column = VAR _t2col = CALCULATE ( MAX ( 'Table 2'[Column1] ), FILTER ( 'Table 2', IFERROR ( SEARCH ( 'Table 1'[Column1], 'Table 2'[Column1], 1, 0 ), 0 ) > 0 ) ) RETURN IF ( ISBLANK ( _t2col ), "No", "Yes" )Best Regards
Yes, it is possible to use DAX to create a new column in Table 1 that indicates whether there is a match in Table 2. One approach could be to use the CONTAINS function to check if the text in Table 2 contains the text in Table 1.
Here is an example DAX formula that you can use to create a new column in Table 1:
=IF(COUNTROWS(FILTER(Table2,CONTAINS(Table2[Text],Table1[Column])))>0,"Yes","No")
This formula uses the FILTER function to identify rows in Table 2 where the text in the [Text] column contains the text in the [Column] column of Table 1. The CONTAINS function performs the actual text comparison. If the FILTER function returns any rows, then the COUNTROWS function will return a value greater than zero, indicating that there is a match. The IF function then returns "Yes" if there is a match, and "No" otherwise.
Note that this formula assumes that the name of the [Text] column in Table 2 is "Text". You may need to adjust the formula accordingly if the actual name of the column is different.
Also, keep in mind that this approach may not be very efficient for large tables, as it requires scanning the entire [Text] column of Table 2 for each row in Table 1. If performance is a concern, you may want to consider other approaches, such as using Power Query to merge the two tables based on a partial match of the [Text] and [Column] columns.