Forum Discussion

amani1980's avatar
amani1980
Frequent Visitor
1 year ago
Solved

Containsstring to compare two columns...

Hi,

 

I have two tables 

 

I want to compare Series with Runs and return an output of the number of occurances of each of the strings in Runs table as a new column COUNTS. Basically in this example, the output would be as shown on the right side of that pic. I can compare single values using CONTAINSSTRING. However, I'm not sure how to compare two columns. Can someone help me?

 

Thanks in advance...!

  • Hi amani1980 ,

     

    You can achieve your goal by writing a measure like the one below:

    CountsMeasure = 
    VAR CurrentSeries = SELECTEDVALUE(Series[Series])
    RETURN
    SUMX(
        Runs,
        IF(CONTAINSSTRING(Runs[Runs], CurrentSeries), 1, 0)
    )
    

    You can either use this measure in a calculated column, as shown below, or place it next to the Series rows in the matrix visual, as demonstrated in the one below.

     

    I have attached an example pbix file for your reference. 

     

2 Replies