Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Contains counter

I have a column with text and i'm trying to create a measure that will count the amount of times two words appear together.

 

For example:

Word 1: Text 1

Word 2: Text 2

 

Text 1 - Text 1 - Text 1 - Text 2
Text 1 - Text 3 - Text 1 - Text 3
Text 1 - Text 2 - Text 1 - Text 1
Text 1 - Text 2 - Text 1 - Text 1

Text 1 - Text 1 - Text 1 - Text 3

Text 1 - Text 1 - Text 1 - Text 3

Text 1 - Text 1 - Text 1 - Text 4

 

Result: 3 (as text 1 and text 2 appear together on 3 different rows)

 

I have the following dax that converts selections in splicers to strings:

 

Mutual_Counter =
    VAR t1 = CONVERT(SELECTEDVALUE(Steps_Affiliate[taxonomy_4]),STRING)
    VAR t2 = CONVERT(SELECTEDVALUE(Steps_Affiliate[taxonomy_4 Filter_2]),STRING)
    VAR inp = CONCATENATE(t1, t2)
    return
    CALCULATE(
        COUNT(Paths[path_taken]),
        CONTAINSSTRING(Paths[path_taken],inp)
    )

 

The code doesn't error, but nothing is returned. Am i using the wrong contains? Or is something else off.

 

TIA

1 Reply

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 

    perhaps you need to include the delimiter (seperator) and spaces. 
    VAR inp = t1 & " - " & t2